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
22/23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{1,0,0,0,1,0,0,1},//5
{1,0,0,0,0,0,0,1},//6
{0,0,1,1,1,1,0,1},//7
{0,0,0,0,0,0,0,1},//8
{0,0,0,0,1,1,0,1} //9
};
void
numberShow(int
i) { //this function is used to display numbers
for(int
pin = 2; pin <= 9 ; pin++){
digitalWrite(pin, number[i][pin ‐ 2]);
}
}
void
setup(){
Serial.begin(9600);
irrecv.enableIRIn();
for(int
pin = 2 ; pin <= 9 ; pin++){
pinMode(pin, OUTPUT);
digitalWrite(pin, HIGH);
}
}
void
loop() {
if
(irrecv.decode(&results)) {
for(int
i = 0; i <= 11; i++){
if(results.value == codes[i]&& i <= 9){
numberShow(i); // display number 0~9 on the digital control
currentNumber = i;
Serial.println(i);
break;
}
else
if(results.value == codes[10]&& currentNumber != 0){
currentNumber‐‐;
numberShow(currentNumber);
Serial.println(currentNumber);
break;
}
//
else
if(results.value == codes[11]&& currentNumber != 9){
curren+;
numberShow(currentNumber);