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

Bluetooth-Controlled Fan System

Uploaded by

raphaelmaju25
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)
5 views2 pages

Bluetooth-Controlled Fan System

Uploaded by

raphaelmaju25
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

#include <SoftwareSerial.

h>

SoftwareSerial BT(0, 1); // RX, TX

const int fanPin = 3;

const int ledPin = 4;

const int buttonPin = 2;

bool fanStatus = false;

void setup() {

pinMode(fanPin, OUTPUT);

pinMode(ledPin, OUTPUT);

pinMode(buttonPin, INPUT_PULLUP);

[Link](9600);

digitalWrite(fanPin, LOW);

digitalWrite(ledPin, LOW);

void loop() {

if ([Link]()) {

String cmd = [Link]('\n');

[Link]();

if (cmd == "ON") {

fanStatus = true;

} else if (cmd == "OFF") {


fanStatus = false;

updateFan();

if (digitalRead(buttonPin) == LOW) {

fanStatus = !fanStatus;

updateFan();

delay(500); // Debounce delay

void updateFan() {

digitalWrite(fanPin, fanStatus ? HIGH : LOW);

digitalWrite(ledPin, fanStatus ? HIGH : LOW);

[Link](fanStatus ? "Fan ON" : "Fan OFF");

You might also like