← All Projects
Bluetooth Home Automation
32 viewsApril 1, 2026
hc-05arduino unorelay modulebulbbluetooth
arduino— code.ino
// Home Automation: Bluetooth Controlled Light
const int relayPin = 13;
char incomingData;
void setup() {
pinMode(relayPin, OUTPUT);
// Default state: Light OFF (Note: Most relays are Active Low)
digitalWrite(relayPin, HIGH);
Serial.begin(9600); // Bluetooth default baud rate
}
void loop() {
if (Serial.available() > 0) {
incomingData = Serial.read();
// Send '1' to turn ON, '0' to turn OFF
if (incomingData == '1') {
digitalWrite(relayPin, LOW); // Relay ON
Serial.println("Light: ON");
}
else if (incomingData == '0') {
digitalWrite(relayPin, HIGH); // Relay OFF
Serial.println("Light: OFF");
}
}
}