CODE:/*Relay IN1 connected to PinOut 2 ArduinoRelay IN2 connected to PinOut 3 ArduinoRelay IN3 connected to PinOut 4 ArduinoRelay IN4 connected to PinOut 5 Arduino--->you can connected to relay modul 4 channelSerial data sending from Arduino 4 Relay.apkdata '1'-'4' to on is Ralay CH 1-4data 'A'-'D' to off is Ralay CH 1-4data '9' to on ALL CH 1-4data 'I' to off ALL CH 1-4*/#include SoftwareSerial mySerial(10, 11); //Pin10 RX , Pin 11 TX connected to--> Bluetooth TX,RX#define relay1 2#define relay
2 3#define relay3 4#define relay4 5char val;void setup() {pinMode(relay1,OUTPUT);pinMode(relay2,OUTPUT);pinMode(relay3,OUTPUT);pinMode(relay4,OUTPUT);digitalWrite(relay1,LOW);//HdigitalWrite(relay2,LOW);//HdigitalWrite(relay3,LOW);//HdigitalWrite(relay4,LOW);//HmySerial.begin(9600);Serial.begin(9600);}void loop() {//chek data serial from bluetooth android Appif( mySerial.available() >0 ) {val = mySerial.read();Serial.println(val); }//Relay is onif( val == '1' ) {digitalWrite(relay1,HIGH); }//Lelse if( val == '2' ) {digitalWrite(relay2,HIGH); }//Lelse if( val == '3' ) {digitalWrite(relay3,HIGH); }//Lelse if( val == '4' ) {digitalWrite(relay4,HIGH); }//L//relay all onelse if( val == '9' ) {digitalWrite(relay1,HIGH);//LdigitalWrite(relay2,HIGH);//LdigitalWrite(relay3,HIGH);//LdigitalWrite(relay4,HIGH);//L}//relay is offelse if( val == 'A' ) {digitalWrite(relay1,LOW); }//Helse if( val == 'B' ) {digitalWrite(relay2,LOW); }//Helse if( val == 'C' ) {digitalWrite(relay3,LOW); }//Helse if( val == 'D' ) {digitalWrite(relay4,LOW); }//H//relay all off else if( val == 'I' ) {digitalWrite(relay1,LOW);//HdigitalWrite(relay2,LOW);//HdigitalWrite(relay3,LOW);//HdigitalWrite(relay4,LOW);//H}}
... moreless ...