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
12/23
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
Ambient Light controlled LED
*/
int
LED = 13; //Led pin
int
val = 0;
void
setup(){
pinMode(LED,OUTPUT);
Serial.begin(9600);
}
void
loop(){
val = analogRead(0); // read voltage value
Serial.println(val);
if(val<1000){ // if the value is less than 1000
,
LED turns off
digitalWrite(LED,LOW);
}else{ // if the value is more than 1000
,
LED turns on
digitalWrite(LED,HIGH);
}
delay(10);
}
10.Moving a Servo