-
Notifications
You must be signed in to change notification settings - Fork 0
/
1_setup_and_loop.ino
47 lines (35 loc) · 1.3 KB
/
1_setup_and_loop.ino
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
void setup() {
Serial.begin(9600); // Starting Serial Terminal-------------------------------
pinMode(vl_pin, INPUT_PULLUP);
digitalWrite(vl_pin, HIGH);
Wire.begin();
vl_sensor.init();
vl_sensor.setTimeout(500);
vl_sensor.startContinuous();
//Servos-------------------------------------------------------------------------
//Setup for Base Servo
searchServo.attach(searchServoPin);
searchServo.write (searchServoStartAngle); //Start Base servo at 0 Degrees
//Setup for Hand Servo----------------------------------------------------------
handServo.attach(handServoPin);
handServo.write(closedHandServoAngle);
//Setup for eye and transistor
pinMode(LED_BUILTIN, OUTPUT); // Set LED_BUILTIN
pinMode(transistorPin, OUTPUT); // Set the Led for the eye as output
//Set Random Seed for WAV files index
randomSeed(analogRead(0));
//Play Open Sound
myMP3.setVolume(volume);
PlayWav(0);
}
/************************************loop Function*********************************/
void loop() {
//If turret has recently spotted a target - it's active
if (isActive == true) {
ActiveFunction();
}
//If turret has lost a target and stopped searching for one - it's deactivated
else {
NotActiveFunction();
}
}