Fading Light - DFRobot DFR0100 Manual

Beginner kit for arduino v3
Table of Contents

Advertisement

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