tojo_kool
Published © CC0

Bluetooth smart led

When someone passes nearer to the device then it asks for a password if we give a correct password then it works.

IntermediateProtip217
Bluetooth smart led

Things used in this project

Hardware components

Bluetooth Low Energy (BLE) Module (Generic)
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
3 mm LED: Red
3 mm LED: Red
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

circuit diagram

Code

Bluetooth smart led

C/C++
#include <SoftwareSerial.h>
SoftwareSerial HM10(8, 9); // RX = 8, TX = 9
char appData;  
String inData = "";
void setup()
{
  Serial.begin(9600);
  Serial.println("HM10 serial started at 9600");
  HM10.begin(9600); // set HM10 serial at 9600 baud rate
  pinMode(13, OUTPUT); // onboard LED
  digitalWrite(13, LOW); // switch OFF LED

}

void loop()
{
  HM10.listen();  // listen the HM10 port
  while (HM10.available() > 0) {   // if HM10 sends something then read
    appData = HM10.read();
    inData = String(appData);  // save the data in string format
    Serial.write(appData);
  }

 
  if (Serial.available()) {           // Read user input if available.
    delay(10);
    HM10.write(Serial.read());
  }
  if ( inData == "F") {
    Serial.println("LED OFF");
    digitalWrite(13, LOW); // switch OFF LED
    delay(500);
  }
  if ( inData == "N") {
    Serial.println("LED ON");
    digitalWrite(13, HIGH); // switch OFF LED
    delay(500);
    digitalWrite(13, LOW); // switch OFF LED
    delay(500);
  }
}

Credits

tojo_kool
1 project • 0 followers

Comments