forked from WRO-2021/Cassiopea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cassiopea.ino
96 lines (73 loc) · 1.77 KB
/
cassiopea.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
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
92
93
94
95
96
//CASSIOPEA prime prove
//(conoscendomi questo commento resterà così per sempre)
//GB
#include "motors.h"
#include "movements.h"
#include "exploration.h"
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
pinMode(12, INPUT); //button
pinMode(2, OUTPUT); //led lack of progress
pinMode(3, OUTPUT); //led victim
pinMode(LED_R, OUTPUT); //led r
pinMode(LED_G, OUTPUT); //led g
pinMode(LED_B, OUTPUT); //led b
digitalWrite(LED_R, HIGH);
digitalWrite(LED_G, HIGH);
digitalWrite(LED_B, HIGH);
pinMode(REFLEX, INPUT);
Wire.begin();
Serial.begin(115200);
//while (!Serial);
Serial.println("Started");
Serial.println("TOFs initialization");
tof_conf_all();
Serial.println("IMU initialization");
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
//else {Serial.println("giro available");}
Serial.println("Gyroscope calibration... do not move the IMU");
gyro_calibrate(500);
//Serial.println(gyro_offset_X);
Serial.println("Motors initialization");
motor_init();
motor_set_speed_both(192);
//tof check
Serial.println("tof check");
for(int i=1; i<8; i++)
{
int dis = tof_read(i);
if(dis == -1)
{
tof_conf(i);
}
}
Serial.println("Setup done");
digitalWrite(LED_BUILTIN, LOW);
////////////////////////////////
campo_init();
allinea_muro();
distanzia_muro();
esplora();
}
void loop()
{
if(digitalRead(12))//in case of lack of progress
{
digitalWrite(LED_BUILTIN, LOW);
esplora();
}
if(millis()%1000<500)
{
digitalWrite(LED_BUILTIN, LOW);
}
else
{
digitalWrite(LED_BUILTIN, HIGH);
}
campo_stampa();
}