0% found this document useful (0 votes)
1 views1 page

Bluetooth

The document is an Arduino sketch that controls four LEDs using Bluetooth commands. Each LED can be toggled on or off by sending a specific character ('1', '2', '3', or '4') via serial communication. The setup initializes the LEDs and serial communication, while the loop listens for commands to change the state of the LEDs accordingly.

Uploaded by

akkundu0809
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views1 page

Bluetooth

The document is an Arduino sketch that controls four LEDs using Bluetooth commands. Each LED can be toggled on or off by sending a specific character ('1', '2', '3', or '4') via serial communication. The setup initializes the LEDs and serial communication, while the loop listens for commands to change the state of the LEDs accordingly.

Uploaded by

akkundu0809
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#define LED1 2

#define LED2 3
#define LED3 4
#define LED4 5
int c1=1,c2=1,c3=1,c4=1;
void setup() {
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);
Serial.begin(9600); // Using hardware serial (pins 0 and 1)
}

void loop() {
if (Serial.available()) {
char command = Serial.read(); // Read Bluetooth data

if (command == '1') {
if(c1==1)
{digitalWrite(LED1, HIGH);
c1=0;}
else {digitalWrite(LED1,LOW);
c1=1;}
}
else if (command == '2') {
if(c2==1)
{digitalWrite(LED2, HIGH);
c2=0;}
else {digitalWrite(LED2,LOW);
c2=1;}
}
else if (command == '3') {
if(c3==1)
{digitalWrite(LED3, HIGH);
c3=0;}
else {digitalWrite(LED3,LOW);
c3=1;}
}
else if (command == '4') {
if(c4==1)
{digitalWrite(LED4, HIGH);
c4=0;}
else {digitalWrite(LED4,LOW);
c4=1;}
}
else{

Serial.println(command);
}
}

You might also like