Bhaskar C
Published © MIT

Blink LED via Mobile Bluetooth

We access the bluetooth module to relay information and convey it via switching LED on/off.

BeginnerProtip5,221
Blink LED via Mobile Bluetooth

Things used in this project

Hardware components

HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Arduino UNO R3
×1

Software apps and online services

Arduino IDE
Arduino IDE
Arduino bluetooth controller

Story

Read more

Schematics

Schematics

Code

bt_blink

Arduino
This code will take '1' as command to turn on the on-board LED and '2' as command to turn off on-board LED. The rest of the characters are ignored.
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()>0)
   {     
      char data= Serial.read(); // reading the data received from the bluetooth module
      switch(data)
      {
        case '1': 
        {
          digitalWrite(LED_BUILTIN, HIGH);
          break;
        }
        case '2': 
        {
          digitalWrite(LED_BUILTIN, LOW);
          break;
        }
        default : break;
      }
      Serial.println(data);
   }
   delay(50);     
}

Credits

Bhaskar C
0 projects • 0 followers
Happy to learn!

Comments