-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sensors.h
75 lines (68 loc) · 1.27 KB
/
Sensors.h
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
// w/ white plug-ins 1 means dark, 0 means light. Reverse when white is plugged in.
#include "WPILib.h"
class IRSensor //The sensors looking at the floor lines
{
public:
DigitalInput *Sensor;
IRSensor::IRSensor(int channel)
{
Sensor=new DigitalInput( channel);
}
IRSensor::IRSensor(int channel, int slot)
{
Sensor=new DigitalInput(slot, channel);
}
bool IRSensor::onLine()
{
//if the sensor is on a line, it will return true.
int num=Sensor->Get();
if(num==!1)
return true;
else
return false;
}
int IRSensor::Get()
{
return Sensor->Get();
}
};
/*
int main()
{
IRSensor IR1(1); //Left
IRSensor IR2(2); //Center
IRSensor IR3(3); //Right
while(true)
{
cout << IR1.Get() << " " << IR2.Get() << " " << IR3.Get() << " " << endl;
}
m_topRight->Set(1);
m_topLeft->Set(1);
m_bottomRight->Set(1);
m_bottomLeft->Set(1);
while(Cookies)
{
if(IR1->onLine()==true)
{
m_topRight->Set(1);
m_topLeft->Set(0);
m_bottomRight->Set(0);
m_bottomLeft->Set(-1);
}
if(IR3->onLine()==true)
{
m_topRight->Set(0);
m_topLeft->Set(1);
m_bottomRight->Set(-1);
m_bottomLeft->Set(0);
}
if(IR2->onLine()==true)
{
m_topRight->Set(1);
m_topLeft->Set(1);
m_bottomRight->Set(1);
m_bottomLeft->Set(1);
}
}
}
*/