Arduino traffic lights

1,966 views

Published on

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,966
On SlideShare
0
From Embeds
0
Number of Embeds
53
Actions
Shares
0
Downloads
84
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Arduino traffic lights

  1. 1. ARDUINO TRAFFIC LIGHTS
  2. 2. ARDUINO UNO
  3. 3. int red = 11; int yellow = 12; int green = 13;
  4. 4. • void setup(){ • pinMode(red,OUTPUT); • pinMode(yellow,OUTPUT); pinMode(green,OUTPUT); }
  5. 5. • int red = 13; int yellow = 12; int green = 11; • void setup(){ pinMode(red,OUTPUT); pinMode(yellow,OUTPUT); pinMode(green,OUTPUT); }
  6. 6. • void loop(){ • changeLights(); delay(15000); } • void changeLights(){ • // green off, yellow for 3 seconds digitalWrite(green,HIGH); • digitalWrite(yellow,LOW); • delay(3000); • // turn off yellow, then turn red on for 5 seconds • digitalWrite(yellow,LOW); digitalWrite(red,HIGH); delay(5000); // red and yellow on for 2 seconds (red is already on though) digitalWrite(yellow,HIGH); delay(2000); // turn off red and yellow, then turn on green digitalWrite(yellow,LOW); digitalWrite(red,LOW); digitalWrite(green,HIGH); }
  7. 7. • void changeLights(){ • // green off, yellow for 3 seconds digitalWrite(green,HIGH); digitalWrite(yellow,LOW); delay(3000);
  8. 8. • • • • • // turn off yellow, then turn red on for 5 seconds digitalWrite(yellow,LOW); digitalWrite(red,HIGH); delay(5000); // turn off red and yellow, then turn on green digitalWrite(yellow,LOW); digitalWrite(red,LOW); digitalWrite(green,HIGH); }
  9. 9. ARDUINO SOFTWARE
  10. 10. Download
  11. 11. Execute
  12. 12. Recognize Arduino (1)
  13. 13. Update the controllers
  14. 14. BLINK CODE
  15. 15. BLINK CODE
  16. 16. Arduino can speak with Processing

×