Bharath Ram
Published

Smart Led (Usage Cost Prediction)

An Android App that controls the LED at predefined time..... And predicts the cost for using it at predefined time for 30 days....

IntermediateFull instructions provided635
Smart Led (Usage Cost Prediction)

Things used in this project

Hardware components

Relay (generic)
×1

Software apps and online services

LED

Story

Read more

Code

Linkit One

Arduino
Linkit One code or Bluetooth Control
#include <LBT.h>
#include <LBTServer.h>
#define SPP_SVR "LED" // it is the server's visible name, customize it yourself.


char buf;

void setup() {
  // put your setup code here, to run once:
  pinMode(13,OUTPUT);
  Serial.begin(9600);
  Serial1.begin(9600);
  bool success = LBTServer.begin((uint8_t*)SPP_SVR);
  if( !success )
  {
      Serial.print("Cannot begin Bluetooth");
      // don't do anything else
      delay(0xffffffff);
  }
  else
  {
      Serial.print("Server created");
  }
 
  // waiting for Spp Client to connect
  bool connected = LBTServer.accept(1800);
 
  if( !connected )
  {
      Serial.print("No connection");
      // don't do anything else
      delay(0xffffffff);
  }
  else
  {
      Serial.print("Connected\n");
  }
}


void loop() {
  // put your main code here, to run repeatedly:
        if(LBTServer.available())
        {
          buf=LBTServer.read();
          Serial.println(buf);
        }
        
        if(buf=='1')
        digitalWrite(13,HIGH);
        else
        digitalWrite(13,LOW);
        
        
        bool con=LBTServer.connected();
        if(!con)
         {
          Serial.println("not connected");
         }
        else
        Serial.println("connected");

        
        delay(500);
}

Credits

Bharath Ram

Bharath Ram

6 projects • 22 followers

Comments