Rajiv SharmaIoTBoysRajivCodeLab
Published © GPL3+

How to Control Home Appliances from PC using Arduino

I will explain the process of how to control home appliances from PC using Arduino board with the help of Serial Communication.

BeginnerProtip2 hours260
How to Control Home Appliances from PC using Arduino

Things used in this project

Hardware components

Arduino Uno
×1
Male to Female Jumper Cable
×5
4 Channel Relay
×1
LED Light Bulb, Frosted GLS
LED Light Bulb, Frosted GLS
×4

Software apps and online services

Arduino IDE
Arduino IDE
IoT Control Tower

Story

Read more

Schematics

Shematics

Code

Arduino Sketch for Controlling Home Appliances from PC

C/C++
String inputString;

void setup() {
  // put your setup code here, to run once: 5-0
  Serial.begin(9600);
  
  for(int pin =0; pin< 14; pin++){
    pinMode(pin, OUTPUT);
    digitalWrite(pin, HIGH);
  }
 
}

void loop() {
  
 inputString = Serial.readString();
 Serial.println(inputString);

  if(inputString != ""){
  
  int delimiterPos = inputString.indexOf('-');

    if (delimiterPos != -1) {
    String pinString = inputString.substring(0, delimiterPos);  
    String stateString = inputString.substring(delimiterPos + 1);  
    
    int pinNumber = pinString.toInt(); 
    int command = stateString.toInt(); //0 = Off or 1 = ON

    if (command == 1) {
      digitalWrite(pinNumber, LOW);
    } else if (command == 0) {
      digitalWrite(pinNumber, HIGH);
    }  
  }  
  }

}

Credits

Rajiv Sharma
18 projects • 72 followers
Having more than 10 years of experience in IoT and software technology. Founded IoTBoys to share knowledge with IoT enthusiasts.
Contact
IoTBoys
9 projects • 115 followers
Watch, Learn and Built IoT projects | DIY IoT Projects | IoT Projects for College Student.
Contact
RajivCodeLab
7 projects • 5 followers
Creates YT videos on DIY IoT Projects: Raspberry Pi Pico, Raspberry Pi Zero, Arduino, ESP32,
Contact

Comments

Please log in or sign up to comment.