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

Bluetooth Home Automation

The document contains an Arduino sketch that utilizes the SoftwareSerial library to control four LEDs via Bluetooth commands. Each LED can be turned on or off using specific character commands ('A', 'B', 'C', 'D' for on and 'a', 'b', 'c', 'd' for off). The setup initializes the serial communication and sets the LED pins as outputs.

Uploaded by

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

Bluetooth Home Automation

The document contains an Arduino sketch that utilizes the SoftwareSerial library to control four LEDs via Bluetooth commands. Each LED can be turned on or off using specific character commands ('A', 'B', 'C', 'D' for on and 'a', 'b', 'c', 'd' for off). The setup initializes the serial communication and sets the LED pins as outputs.

Uploaded by

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

#include <SoftwareSerial.

h>

SoftwareSerial bluetooth(2, 3); // RX, TX pins for Bluetooth module

int ledPin1 = 9; // Pin for LED 1


int ledPin2 = 10; // Pin for LED 2
int ledPin3 = 11; // Pin for LED 3
int ledPin4 = 12; // Pin for LED 3

void setup() {
Serial.begin(9600);

pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);

digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, LOW);

void loop() {
if (bluetooth.available()) {
char command = bluetooth.read();

if (command == 'A') {
digitalWrite(ledPin1, HIGH);
} else if (command == 'a') {
digitalWrite(ledPin1, LOW);
} else if (command == 'B') {
digitalWrite(ledPin2, HIGH);
} else if (command == 'b') {
digitalWrite(ledPin2, LOW);
} else if (command == 'C') {
digitalWrite(ledPin3, HIGH);
} else if (command == 'c') {
digitalWrite(ledPin3, LOW);
} else if (command == 'D') {
digitalWrite(ledPin4, HIGH);
} else if (command == 'd') {
digitalWrite(ledPin4, LOW);
}
}

You might also like