Arduino Bluetooth Switch

Arduino Bluetooth Switch is a simple project controlled by using HC-05 bluetooth module and Arduino UNO using this you can make home automation system or remote controlled toys, etc.

Things what you gonna need:

1 X HC-05 bluetooth module

1 X Arduino uno

4 X Jumper wires

 

 

CODE:

 

int ledPin = 13;
int state = 0;
int flag = 0;

void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);

Serial.begin(9600); // Default connection rate for my BT module
}

void loop() {

if(Serial.available() > 0){
state = Serial.read();
flag=0;
}

if (state == ‘0’) {
digitalWrite(ledPin, LOW);
if(flag == 0){
Serial.println(“LED: off”);
flag = 1;
}
}

else if (state == ‘1’) {
digitalWrite(ledPin, HIGH);
if(flag == 0){
Serial.println(“LED: on”);
flag = 1;
}
}
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *