Last active
April 19, 2019 05:49
-
-
Save idriszmy/7f1ca769e93b286026f0072682ffaf81 to your computer and use it in GitHub Desktop.
Menghasilkan corak cahaya berlari LED di papan Maker UNO.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Fungsi kod: Menghasilkan corak cahaya LED di | |
papan Maker UNO. | |
Penulis: Idris Zainal Abidin | |
Blog: https://idrisz.my | |
Kemaskini: 19 April 2019 | |
*/ | |
int ledPin = 0; // Pemboleh ubah pin LED | |
void setup() | |
{ | |
// Tetapkan semua pin 2 hingga 13 yang bersambung | |
// dengan LED sebagai keluaran | |
for (ledPin = 2; ledPin < 14; ledPin++) { | |
pinMode(ledPin, OUTPUT); | |
} | |
} | |
void loop() | |
{ | |
// Nyalakan LED satu persatu dari pin 2 hingga pin 13 | |
for (ledPin = 2; ledPin < 15; ledPin++) { | |
digitalWrite(ledPin, HIGH); // Nyalakan LED semasa | |
digitalWrite(ledPin-1, LOW); // Padamkan LED sebelumnya | |
delay(100); // Tunggu 100 ms | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment