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

Cod

Uploaded by

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

Cod

Uploaded by

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

#include <SoftwareSerial.

h>

SoftwareSerial bluetooth(0, 1); // RX, TX pins for Bluetooth module

char command; // Variable to store incoming commands from Bluetooth

void setup() {
Serial.begin(9600); // Set up serial communication
bluetooth.begin(9600); // Set up Bluetooth communication
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);// Set LED pin as output
}

void loop() {
if (bluetooth.available()) { // Check if data is available to read from Bluetooth
command = bluetooth.read(); // Read the incoming command from Bluetooth

// Check the command received and perform corresponding action


switch (command) {
case '2':
digitalWrite(6, LOW); // Turn off LED
Serial.println("LED turned off");
break;
case '1':
digitalWrite(6, HIGH); // Turn on LED
Serial.println("FAN turned on");
break;
case '4':
digitalWrite(7, LOW); // Turn off LED
Serial.println("LED turned off");
break;
case '3':
digitalWrite(7, HIGH); // Turn on LED
Serial.println("LED turned on");
break;
default:
Serial.println("Invalid command");
}
}
}
ULN2003AN

You might also like