Tutorial Membuat LED Berjalan berbasis Arduino Nano R3

Berikut adalah Tutorial Membuat LED Berjalan berbasis Arduino Nano R3

Ini adalah sketch program arduino

/*
10_Led Berjalan
*/

int i = 0;

void setup()
{
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);

for (i = 2; i <= 9; i++)
{
digitalWrite(i, LOW);
}
}

void loop()
{
for (i = 2; i <= 9; i++)
{
digitalWrite(i, HIGH);
delay(500);
}
for (i = 9; i >= 2; i–)
{
digitalWrite(i, LOW);
delay(500);
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *