forked from mdwyer421/juniorDesignProjectSpring2019
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservoControl.c.txt
More file actions
83 lines (69 loc) · 1.41 KB
/
Copy pathservoControl.c.txt
File metadata and controls
83 lines (69 loc) · 1.41 KB
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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <IRremote.h>
#include <Servo.h>
Servo updown;
Servo leftright;
const int ir= 7;
IRrecv irrecv(ir);
decode_results results;
int input=0;
int vpos=90;
int hpos=90;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
leftright.attach(9);
updown.attach(10);
updown.write(90);
leftright.write(90);
}
void loop(){
if (irrecv.decode(&results)){
Serial.println(results.value, DEC);//
input=(results.value);
Serial.println(input);
moveCam();
irrecv.resume();
//delay(600);
}
}
void moveCam(){
if(input==16625743)//down
{
if(vpos<180){
vpos+=10;
updown.write(vpos);
return;
}
}//end down
else if(input==16621663)//up
{
if(vpos>0){
vpos-=10;
updown.write(vpos);
return;
}
}//end up
else if(input==16584943)//left
{
if(hpos<180){
hpos+=10;
leftright.write(hpos);
return;
}
}//end left
else if(input==16601263)//right
{
if(hpos>0){
hpos-=10;
leftright.write(hpos);
return;
}
}//end right
else if(input==16617583){
updown.write(90);
leftright.write(90);
hpos=90;
vpos=90;
}
}