#include <SoftwareSerial.h> //including library for Software Serial communication SoftwareSerial mySerial (2, 3); //(RX, TX) //defining all the pins of Arduino #define s1 10 #define s2 11 #define s3 12 #define s4 13 void setup() { //setting all the pins pinMode(s1, OUTPUT); pinMode(s2, OUTPUT); pinMode(s3, OUTPUT); pinMode(s4, OUTPUT); //defining baudrate Serial.begin(9600); mySerial.begin(9600); } void loop() { if (mySerial.available() == 1) //if communication is going on { char val = mySerial.read(); //Read the data recieved Serial.println("Recieved data is " + (String) val); if (val == 'A') { digitalWrite(s1, HIGH); Serial.println("Switch 1 is ON"); } if (val == 'a') { digitalWrite(s1, LOW); Serial.println("Switch 1 is OFF"); } if (val == 'B') { digitalWrite(s2, HIGH); Serial.println("Switch 2 is ON"); }