0% found this document useful (0 votes)
4 views2 pages

Arduino Bluetooth Relay Control Code

This document contains an Arduino sketch that uses the SoftwareSerial library to control two relays for a light and a fan. It sets up serial communication and listens for commands via Bluetooth to turn the devices on or off. The commands '1' and '2' control the light, while '3' and '4' control the fan.

Uploaded by

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

Arduino Bluetooth Relay Control Code

This document contains an Arduino sketch that uses the SoftwareSerial library to control two relays for a light and a fan. It sets up serial communication and listens for commands via Bluetooth to turn the devices on or off. The commands '1' and '2' control the light, while '3' and '4' control the fan.

Uploaded by

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

#include <SoftwareSerial.

h>

SoftwareSerial BTSerial(10, 11); // RX, TX

const int relay1 = 2;

const int relay2 = 3;

void setup() {

pinMode(relay1, OUTPUT);

pinMode(relay2, OUTPUT);

[Link](9600);

[Link](9600);

void loop() {

if ([Link]()) {

char command = [Link]();

if (command == '1') {

digitalWrite(relay1, HIGH); // Turn on light

} else if (command == '2') {

digitalWrite(relay1, LOW); // Turn off light

} else if (command == '3') {

digitalWrite(relay2, HIGH); // Turn on fan

} else if (command == '4') {

digitalWrite(relay2, LOW); // Turn off fan


}

You might also like