exp9 led and buzzer uing bluetooth

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#define LED1 4 // LED Strip to (5v scl sda gnd) connector

#define LED2 5
#define BUZZER 14 //buzzer to D5 connector
// Bluetooth mocdule to (5v Tx Rx Gnd) connector
char input;

void setup()
{
Serial.begin(9600);
Serial.println("Bluetooth Started");
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(BUZZER, OUTPUT);
}

void loop()
{

if (Serial.available() > 0)
{
input = Serial.read();
Serial.print(input);
if (input == 'A')
{
Serial.println("A Received");
digitalWrite(LED1, HIGH);
delay(250);
}
else if (input == 'a')
{
Serial.println("a Received");
digitalWrite(LED1, LOW);
delay(250);
}
if (input == 'B')
{
Serial.println("B Received");
digitalWrite(LED2, HIGH);
delay(250);
}
else if (input == 'b')
{
Serial.println("b Received");
digitalWrite(LED2, LOW);
delay(250);
} if (input == 'C')
{
Serial.println("C Received");
digitalWrite(BUZZER, HIGH);
delay(250);
}
else if (input == 'c')
{
Serial.println("c Received");
digitalWrite(BUZZER, LOW);
delay(250);
}
}
input = '\n';
}

You might also like