-
Notifications
You must be signed in to change notification settings - Fork 0
/
VisionSensorsDevices.cpp
92 lines (75 loc) · 1.84 KB
/
VisionSensorsDevices.cpp
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
84
85
86
87
88
89
90
91
#include "VisionSensorsDevices.h"
#include "VisionSensor.h"
#include "pins_little_robot.h"
#include <elapsedMillis.h>
#define STOPPED 0
#define STOPPING 1
#define RUNNING 2
#define STARTING 3
elapsedMillis waitTime;
//boolean FirstBallFlag = true;
const int delayActions = 4000;
const int delayBallShotsTogglesHigh = 10;
const int delayBallShotsTogglesLow = 40;
//const int ballToggleTimes = 9999999;
//int toggleCounter;
void sensors_and_devices::init()
{
//FirstBallFlag = true;
//toggleCounter = 0;
pinMode(PrepareBallPin, OUTPUT);
digitalWrite(PrepareBallPin, LOW);
pinMode(ShootBallPin, OUTPUT);
digitalWrite(ShootBallPin, LOW);
pinMode(ThrowNetPin, OUTPUT);
digitalWrite(ThrowNetPin, LOW);
back.initPin(BackSenzorPin);
front.initPin(FrontSenzorPin);
left.initPin(LeftSenzorPin);
right.initPin(RightSenzorPin);
}
void sensors_and_devices::shootBall()
{
//if(toggleCounter<=ballToggleTimes){
if(waitTime>delayBallShotsTogglesHigh){
digitalWrite(ShootBallPin, HIGH);
}
if(waitTime>(delayBallShotsTogglesHigh + delayBallShotsTogglesLow))
{
digitalWrite(ShootBallPin, LOW);
//toggleCounter++;
waitTime = 0;
}
//}
}
void sensors_and_devices::startShooting()
{
digitalWrite(ShootBallPin, HIGH);
}
void sensors_and_devices::stopShooting()
{
digitalWrite(ShootBallPin, LOW);
}
void sensors_and_devices::startSpinningBallTray()
{
digitalWrite(PrepareBallPin, HIGH);
waitTime = 0;
}
void sensors_and_devices::stopSpinningBallTray()
{
digitalWrite(PrepareBallPin, LOW);
}
void sensors_and_devices::ThrowNet()
{
digitalWrite(ThrowNetPin, HIGH);
delay(delayActions);
digitalWrite(ThrowNetPin, LOW);
}
int sensors_and_devices::detectColor()
{
return analogRead(ColourSensorPin5);
}
void sensors_and_devices::ColourSensor()
{
blackLineDetected = !blackLineDetected;
}