Arduino 4 Relay Bluetooth 1.0

License: Free ‎File size: N/A
‎Users Rating: 0.0/5 - ‎0 ‎votes

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 channel

Serial 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

#define relay1 2#define relay2 3#define relay3 4#define relay4 5

char 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 Appval = 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 offelse if( val == 'I' ) {digitalWrite(relay1,LOW);//HdigitalWrite(relay2,LOW);//HdigitalWrite(relay3,LOW);//HdigitalWrite(relay4,LOW);//H}

}

VERSION HISTORY

  • Version 1.0 posted on 2016-10-31

Program Details