Klik op het plaatje voor een grotere afbeelding.


 #include <SoftwareSerial.h>

/*
 Stoplicht programma van Thomas
Verkeersstoplicht voor de voetganger en de auto
*/

// Pin 13 has an LED connected on most Arduino boards.
int groen = 5;
int geel = 6;
int rood = 7;
int knop = 12;
int groen2 = 3;
int rood2 = 4;



// the setup routine runs once when you press reset:
void setup() {                
 // initialize the digital pin as an output.
 pinMode(groen, OUTPUT);
 pinMode(geel, OUTPUT);
 pinMode(rood, OUTPUT);
 pinMode(knop, INPUT);
 pinMode(groen2, OUTPUT);
 pinMode(rood2, OUTPUT);
 digitalWrite(groen, HIGH);   // turn the LED on (HIGH is the voltage level)
 digitalWrite(rood, LOW); digitalWrite(geel, LOW);
 digitalWrite(rood2, HIGH);
 digitalWrite(groen2, LOW);
 

}

// the loop routine runs over and over again forever:
void loop() {
int  gedrukt = digitalRead (knop);
 if(gedrukt==HIGH)
     {gedrukt=LOW;
   //  delay(1000);      // wait for a second
     digitalWrite(groen, LOW);    // turn the LED off by making the voltage LOW
     digitalWrite(geel, HIGH);
     delay(1000);
     digitalWrite(geel, LOW);  
     digitalWrite(rood, HIGH);
     delay(500);
     digitalWrite(rood2, LOW);
      digitalWrite(groen2, HIGH);
     delay(6000);
     digitalWrite(groen2, LOW); delay (100); digitalWrite(groen2, HIGH); delay (100);
     digitalWrite(groen2, LOW); delay (100); digitalWrite(groen2, HIGH); delay (100);
     digitalWrite(groen2, LOW); delay (100); digitalWrite(groen2, HIGH); delay (100);
     digitalWrite(groen2, LOW); delay (100); digitalWrite(groen2, HIGH); delay (100);
     digitalWrite(groen2, LOW); delay (100); digitalWrite(groen2, HIGH); delay (100);
     digitalWrite(groen2, LOW); delay (100); digitalWrite(groen2, HIGH); delay (100);
     digitalWrite(groen2, LOW); delay (100); digitalWrite(groen2, HIGH); delay (100);
     digitalWrite(groen2, LOW); delay (100); digitalWrite(groen2, HIGH); delay (100);
     digitalWrite(groen2, LOW);
     digitalWrite(rood2,HIGH);
     delay(500);
     digitalWrite(rood, LOW);
     digitalWrite(groen, HIGH);   // turn the LED on (HIGH is the voltage level)
       
   
 
 }
}