Friday, November 6, 2020

[Arduiono Tutorial #2] - Belajar pemograman arduino sederhana menjalankan 8 LED


 

 Program Arduino :

int i;
void setup() {
  // initialize digital pin LED as an output.
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT); 
}

// the loop function runs over and over again forever
void loop() {
  for (i=1;i<=8;i++)
  {
  digitalWrite(i, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);   // wait for 50 milisecond
  digitalWrite(i, LOW);   // turn the LED off (HIGH is the voltage level)
  //delay(50);
  }

   for (i=8;i>=1;i--)
  {
  digitalWrite(i, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);   // wait for 50 mili second
  digitalWrite(i, LOW);   // turn the LED on (LOW is the voltage level)
  //delay(50);
  }                      
}

No comments:

Post a Comment

Membuat Counter mundur menuju Azan dengan Arduino Wemos

Membuat Counter Mundur Menuju Azan dengan Arduino Wemos  #include <Wire.h> #include "RTClib.h" #include "SPI.h" #i...