arduino traffic lights

20
ARDUINO TRAFFIC LIGHTS

Upload: qichengpan

Post on 31-Aug-2014

884 views

Category:

Business


31 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Arduino traffic lights

ARDUINO TRAFFIC LIGHTS

Page 2: Arduino traffic lights

ARDUINO UNO

Page 3: Arduino traffic lights
Page 4: Arduino traffic lights
Page 5: Arduino traffic lights

int red = 11; int yellow = 12; int green = 13;

Page 6: Arduino traffic lights

• void setup(){• pinMode(red,OUTPUT); • pinMode(yellow,OUTPUT);

pinMode(green,OUTPUT); }

Page 7: Arduino traffic lights
Page 8: Arduino traffic lights

• int red = 13; int yellow = 12; int green = 11; • void setup(){ pinMode(red,OUTPUT);

pinMode(yellow,OUTPUT); pinMode(green,OUTPUT); }

Page 9: Arduino traffic lights

• 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); }

Page 10: Arduino traffic lights

• void changeLights(){ • // green off, yellow for 3 seconds

digitalWrite(green,HIGH); digitalWrite(yellow,LOW); delay(3000);

Page 11: Arduino traffic lights

• // 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); }

Page 12: Arduino traffic lights

ARDUINO SOFTWARE

Page 13: Arduino traffic lights

Download

Page 14: Arduino traffic lights

Execute

Page 15: Arduino traffic lights
Page 16: Arduino traffic lights

Recognize Arduino (1)

Page 17: Arduino traffic lights

Update the controllers

Page 18: Arduino traffic lights

BLINK CODE

Page 19: Arduino traffic lights

BLINK CODE

Page 20: Arduino traffic lights

Arduino can speak with Processing