-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBottone.ino
68 lines (59 loc) · 1.4 KB
/
Bottone.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
#include <Servo.h>;
Servo mx;
int ang_x=0;
int ang_x_1=0;
int ang_y=0;
void setup() {
Serial.begin(9600);
}
int scelta=0;
void loop() {
if (scelta==0){
Serial.println("ARDUINO CONNESSO");
Serial.println("Digita di quanti gradi devono girare i motori");
scelta=1;
}
else if (scelta==1)
{
if (n!=0){
ang_x=n;
scelta=2;
}
}
else if (scelta==2)
{
ang_y=n;
scelta=1;
}
if (Serial.available() > 0){ //Controlliamo se ci sono dati da leggere
int n;
n = Serial.parseInt(); //Legge il numero
Serial.println(n);
if (ang_x>=180){
if (ang_x<258){
ang_x_1 = ang_x-179;
ang_x = ang_x - ang_x_1;
}
else if (ang_x>258)
{
ang_x=0;
ang_x_1=0
}
}
if (ang_y>=180){
ang_y=10;
}
}
}
/*char carattere;
if (Serial.available() > 0){ //Controlliamo se ci sono dati da leggere
carattere = Serial.read(); //Leggiamo un carattere
if (carattere != '\n'){ //Se il carattere non è l'invio
Serial.print("ARDUINO: ");
Serial.println(carattere); //Lo scriviamo indietro
}
elif (carattere == 'q'){
Serial.print("90°→")
}
}*/
}