Postingan lainnya
program Bahasa C
maaf mau nanya gimana cara nambah program nya jika salah satu dari Mv > 40 maka akan eksekusi void E ?
delay(500); if (mv > 33) {A();delay(10000);netral();lcd.clear();goto awal;} else if (mv1 > 33){B();delay(10000);netral();lcd.clear();goto awal;} else if (mv2 > 33){C();delay(10000);netral();lcd.clear();goto awal;} else if (mv3 > 33){D();delay(10000);netral();lcd.clear();goto awal;} else { delay(5000);netral();lcd.clear();goto awal; }
}
//======================BLOK GERAK SERVO============// void A() { myservo1.write(45); myservo2.write(90); myservo3.write(90); myservo4.write(135); myservo5.write(135); myservo6.write(90); digitalWrite(POMPA1,HIGH); digitalWrite(POMPA2,LOW); digitalWrite(POMPA3,LOW); digitalWrite(POMPA4,HIGH); digitalWrite(POMPA5,HIGH); digitalWrite(POMPA6,LOW); }
void B() { myservo1.write(135); myservo2.write(45); myservo3.write(90); myservo4.write(90); myservo5.write(135); myservo6.write(90); digitalWrite(POMPA1,HIGH); digitalWrite(POMPA3,LOW); digitalWrite(POMPA2,HIGH); digitalWrite(POMPA4,LOW); digitalWrite(POMPA5,HIGH); digitalWrite(POMPA6,LOW); }
void C() { myservo1.write(90); myservo2.write(135); myservo3.write(45); myservo4.write(90); myservo5.write(90); myservo6.write(135); digitalWrite(POMPA1,LOW); digitalWrite(POMPA2,HIGH); digitalWrite(POMPA3,HIGH); digitalWrite(POMPA4,LOW); digitalWrite(POMPA5,LOW); digitalWrite(POMPA6,HIGH); } /////////////////////////////////// void D() { myservo1.write(90); myservo2.write(90); myservo3.write(135); myservo4.write(45); myservo5.write(90); myservo6.write(45); digitalWrite(POMPA3,HIGH); digitalWrite(POMPA4,HIGH); digitalWrite(POMPA6,HIGH); } // TAMBAHAN PROGRAM ANE/////////////////////////////// void E()
{ myservo1.write(45); myservo2.write(45); myservo3.write(45); myservo4.write(45); myservo5.write(135); myservo6.write(45); digitalWrite(POMPA1,HIGH); digitalWrite(POMPA2,HIGH); digitalWrite(POMPA3,HIGH); digitalWrite(POMPA4,HIGH); digitalWrite(POMPA5,HIGH); digitalWrite(POMPA6,HIGH); delay (1000); myservo1.write(135); myservo2.write(135); myservo3.write(135); myservo4.write(135); myservo5.write(135); myservo6.write(135); digitalWrite(POMPA1,HIGH); digitalWrite(POMPA2,HIGH); digitalWrite(POMPA3,HIGH); digitalWrite(POMPA4,HIGH); digitalWrite(POMPA5,HIGH); digitalWrite(POMPA6,HIGH); } ///////////////////////////////////////////// void netral() { myservo1.write(90); myservo2.write(90); myservo3.write(90); myservo4.write(90); myservo5.write(90); myservo6.write(90); digitalWrite(POMPA1,LOW); digitalWrite(POMPA2,LOW); digitalWrite(POMPA3,LOW); digitalWrite(POMPA4,LOW); digitalWrite(POMPA5,LOW); digitalWrite(POMPA6,LOW); } ///////////////////////////////////////////
1 Jawaban:
tinggal di rubah saja MV nya jd MV > 40 kemudian panggil sub program E(); sperti ini: if (mv > 40) {E();delay(10000);netral();lcd.clear();goto awal;}