DFRobot DFR0100 Manual page 5

Beginner kit for arduino v3
Table of Contents

Advertisement

25/06/2015
16
    pinMode(carYellow, OUTPUT);
17
    pinMode(carGreen, OUTPUT);
18
    pinMode(pedRed, OUTPUT);
19
        pinMode(pedGreen, OUTPUT);
20
        pinMode(button, INPUT);
21
        digitalWrite(carGreen, HIGH); //turn on the green lights
22
    digitalWrite(pedRed, HIGH);
23
}
24
 
25
 
void
loop() {
26
 
    int
state = digitalRead(button);
27
        //check if button is pressed and it is over 5 seconds since last button press
28
        if(state == HIGH && (millis() ‐ changeTime)> 5000){
29
               //call the function to change the lights
30
               changeLights();
31
        }
32
}
33
 
34
 
void
changeLights() {
35
    digitalWrite(carGreen, LOW); //green off
36
    digitalWrite(carYellow, HIGH); //yellow on
37
    delay(2000); //wait 2 seconds
38
 
        
39
    digitalWrite(carYellow, LOW); //yellow off
40
    digitalWrite(carRed, HIGH); //red on
41
        delay(1000); //wait 1 second till its safe
42
 
        
43
    digitalWrite(pedRed, LOW); //ped red off
44
    digitalWrite(pedGreen, HIGH); //ped green on
45
 
46
    delay(crossTime); //wait for preset time period
47
 
        
48
    //flash the ped green
49
 
 
        for
(int
50
            digitalWrite(pedGreen, HIGH);
51
        delay(250);
52
        digitalWrite(pedGreen, LOW);
53
        delay(250);
54
         }
55
 
                
56
        digitalWrite(pedRed, HIGH);//turn ped red on
57
    delay(500);
58
 
59
    digitalWrite(carRed, LOW); //red off
60
    digitalWrite(carYellow, HIGH); //yellow on 
http://www.dfrobot.com/wiki/index.php/DFRduino_Beginner_Kit_For_Arduino_V3_SKU:DFR0100
DFRduino Beginner Kit For Arduino V3 SKU:DFR0100 ­ Robot Wiki
x=0; x<10; x++) {
5/23

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DFR0100 and is the answer not in the manual?

Questions and answers

Table of Contents