News Update :

Pengikut

Diberdayakan oleh Blogger.

Label

Label

Label

Hot News »
Bagikan kepada teman!

Simulasi Lampu Lalu Lintas dengan Arduino

Alat ini digunakan untuk mensimulasikan lampu lalu lintas, bahan yang digunakan terdiri dari arduino, lampu led, dan resistor,  dan aplikasi yang digunakan menggunakan arduino IDE.



Source Code atau Sketch arduino :

void setup() {

  for(char i=2;i<14;i++){
    pinMode(i, OUTPUT);
  }

  for(char i=2;i<14;i++){
    digitalWrite(i, 0); 
  }

  digitalWrite(2,1);
  digitalWrite(7,1);
  digitalWrite(10,1);
  digitalWrite(13,1);
}

void loop() {

  digitalWrite(2,1);
  digitalWrite(3,0);
  digitalWrite(4,0);
  delay(5000);  

  digitalWrite(2,0);
  digitalWrite(3,1);
  digitalWrite(4,0);
  delay(2000);
  

  digitalWrite(2,0);
  digitalWrite(3,0);
  digitalWrite(4,1);
  delay(1000);  

  digitalWrite(5,1);
  digitalWrite(6,0);
  digitalWrite(7,0);
  delay(5000);  

  digitalWrite(5,0);
  digitalWrite(6,1);
  digitalWrite(7,0);
  delay(2000);
  
  digitalWrite(5,0);
  digitalWrite(6,0);
  digitalWrite(7,1);
  delay(1000);  

  digitalWrite(8,1);
  digitalWrite(9,0);
  digitalWrite(10,0);
  delay(5000);  

  digitalWrite(8,0);
  digitalWrite(9,1);
  digitalWrite(10,0);
  delay(2000);
  
  digitalWrite(8,0);
  digitalWrite(9,0);
  digitalWrite(10,1);
  delay(1000);  

  digitalWrite(11,1);
  digitalWrite(12,0);
  digitalWrite(13,0);
  delay(5000);  

  digitalWrite(11,0);
  digitalWrite(12,1);
  digitalWrite(13,0);
  delay(2000);

  digitalWrite(11,0);
  digitalWrite(12,0);
  digitalWrite(13,1);
  delay(1000);  
}

Arsip Blog

Kontributor

 
Company Info | Contact Us | Privacy policy | Term of use | Widget | Advertise with Us | Site map
Copyright © 2011. elektra solution . All Rights Reserved.
Design Template by panjz-online | Support by creating website | Powered by Blogger