Untitled
unknown
plain_text
a month ago
1.4 kB
3
Indexable
Never
// pengalamatan pin yang digunakan #define Led_R 2 //pin 2 sbg Led_R #define Led_K 4 //pin 4 sbg Led_K #define Led_H 7 //pin 7 sbg Led_H #define Led_B 8 //pin 8 sbg Led_B void setup() { // diatur pin yg sudah di set sbg OUTPUT pinMode(Led_R, OUTPUT); pinMode(Led_K, OUTPUT); pinMode(Led_H, OUTPUT); pinMode(Led_B, OUTPUT); } void loop() { //program diawali dng Led_R berlogika "1" atau HIGH dng time yg di set 1000ms atau 1 detik digitalWrite(Led_R, 1); digitalWrite(Led_K, 0); digitalWrite(Led_H, 0); digitalWrite(Led_B, 0); delay(1000); //program diawali dng Led_B berlogika "1" atau HIGH dng time yg di set 2000ms atau 2 detik digitalWrite(Led_R, 0); digitalWrite(Led_K, 0); digitalWrite(Led_H, 0); digitalWrite(Led_B, 1); delay(2000); //program ini digunakan untuk perulangan sebanyak 5 kali yaitu Led_K nyala mati dengan time yg di set 500ms for (int i = 0; i < 5; i++) { digitalWrite(Led_R, 0); digitalWrite(Led_K, 1); digitalWrite(Led_H, 0); digitalWrite(Led_B, 0); delay(500); digitalWrite(Led_R, 0); digitalWrite(Led_K, 0); digitalWrite(Led_H, 0); digitalWrite(Led_B, 0); delay(500); } //program diakhiri dng Led_H berlogika "1" atau HIGH dng time yg di set 3000ms atau 3 detik digitalWrite(Led_R, 0); digitalWrite(Led_K, 0); digitalWrite(Led_H, 1); digitalWrite(Led_B, 0); delay(3000); }
Leave a Comment