Instructions

25/06/2015 DFRduinoBeginnerKitForArduinoV3SKU:DFR0100RobotWiki
http://www.dfrobot.com/wiki/index.php/DFRduino_Beginner_Kit_For_Arduino_V3_SKU:DFR0100 6/23
61
62
63
64
65
66
67
delay(1000);
digitalWrite(carYellow,LOW);//yellowoff
digitalWrite(carGreen,HIGH);
changeTime=millis();//recordthetimesincelastchangeoflights
//thenreturntothemainprogramloop
}
4.FadingLight
TheconnectiondiagramisthesamewithBlinknigaLEDtutorial.
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
FadingLight
ThisexampleshowshowtofadeanLEDonpin10usingtheanalogWrite()function.
*/
intledPin=10;//thepinthattheLEDisattachedto
voidsetup(){
//declarepin9tobeanoutput:
pinMode(ledPin,OUTPUT);
//initializeserialcommunicationat9600bitspersecond:
Serial.begin(9600);
}
voidloop(){
fadeOn(1000,5);
fadeOff(1000,5);
}
voidfadeOn(unsignedinttime,intincreament){
//changethebrightnessbyFORstatement
for(bytevalue=0;value<255;value+=increament){
//printoutthevalue:
Serial.println(value);
//setthebrightnessofpin10:
analogWrite(ledPin,value);
delay(time/(255/5));
}
}