Arduino Bluetooth 8 Röle Kontrol

8 li role kontrol ares dosyası

Role_8_kontrol apk dosyası

Role_8_kontrol aia dosyası

Kodlar:

String data;
int role1 = 9;
int role2 = 8;
int role3 = 7;
int role4 = 6;
int role5 = 5;
int role6 = 4;
int role7 = 3;
int role8 = 2;

void setup() {
pinMode(role1,OUTPUT);
pinMode(role2,OUTPUT);
pinMode(role3,OUTPUT);
pinMode(role4,OUTPUT);
pinMode(role5,OUTPUT);
pinMode(role6,OUTPUT);
pinMode(role7,OUTPUT);
pinMode(role8,OUTPUT);
digitalWrite(role1,LOW);
digitalWrite(role2,LOW);
digitalWrite(role3,LOW);
digitalWrite(role4,LOW);
digitalWrite(role5,LOW);
digitalWrite(role6,LOW);
digitalWrite(role7,LOW);
digitalWrite(role8,LOW);
Serial.begin(9600);
}

void loop() {
while(Serial.available())
{
delay(10);
data += char(Serial.read());
}
if(data.length() >0) {
Serial.println(data);

if(data == “oneclose”) {digitalWrite(role1,LOW);}
if(data == “oneopen”) {digitalWrite(role1,HIGH);}

if(data == “twoclose”) {digitalWrite(role2,LOW);}
if(data == “twoopen”) {digitalWrite(role2,HIGH);}

if(data == “threeclose”) {digitalWrite(role3,LOW);}
if(data == “threeopen”) {digitalWrite(role3,HIGH);}

if(data == “fourclose”) {digitalWrite(role4,LOW);}
if(data == “fouropen”) {digitalWrite(role4,HIGH);}

if(data == “fiveclose”) {digitalWrite(role5,LOW);}
if(data == “fiveopen”) {digitalWrite(role5,HIGH);}

if(data == “sixclose”) {digitalWrite(role6,LOW);}
if(data == “sixopen”) {digitalWrite(role6,HIGH);}

if(data == “sevenclose”) {digitalWrite(role7,LOW);}
if(data == “sevenopen”) {digitalWrite(role7,HIGH);}

if(data == “eightclose”) {digitalWrite(role8,LOW);}
if(data == “eightopen”) {digitalWrite(role8,HIGH);}

if(data == “allopen”){
digitalWrite(role1,HIGH);
digitalWrite(role2,HIGH);
digitalWrite(role3,HIGH);
digitalWrite(role4,HIGH);
digitalWrite(role5,HIGH);
digitalWrite(role6,HIGH);
digitalWrite(role7,HIGH);
digitalWrite(role8,HIGH);}

if(data == “allclose”){
digitalWrite(role1,LOW);
digitalWrite(role2,LOW);
digitalWrite(role3,LOW);
digitalWrite(role4,LOW);
digitalWrite(role5,LOW);
digitalWrite(role6,LOW);
digitalWrite(role7,LOW);
digitalWrite(role8,LOW);}
data = “”;
}
}