25/06/2015
DFRduino Beginner Kit For Arduino V3 SKU:DFR0100 Robot Wiki
http://www.dfrobot.com/wiki/index.php/DFRduino_Beginner_Kit_For_Arduino_V3_SKU:DFR0100
15/23
12.RGB Light Dimmer
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
RGB Light Dimmer
*/
int
redPin = 9; // R – digital 9
int
greenPin = 10; // G – digital 10
int
bluePin = 11; // B – digital 11
int
potRedPin = 0; // potentiometer 1 – analog 0
int
potGreenPin = 1; // potentiometer 2 – analog 1
int
potBluePin = 2; // potentiometer 3 – analog 2
void
setup(){
pinMode(redPin,OUTPUT);
pinMode(greenPin,OUTPUT);
pinMode(bluePin,OUTPUT);
Serial.begin(9600);
}
void
loop(){
int
potRed = analogRead(potRedPin);
int
potGreen = analogRead(potGreenPin);
int
potBlue = analogRead(potBluePin);