Skip to content

Commit c0156c7

Browse files
committed
Update quadripod.ino
1 parent e15b80e commit c0156c7

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

quadripod.ino

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ SoftwareSerial BT(ARDU_RX, ARDU_TX);
3131
#define LEFT 2
3232
#define RIGHT 3
3333
#define STOP 4
34-
#define START_CMD_CHAR '*'
34+
#define SPEED_CMD_CHAR 's'
35+
#define LEFT_CMD_CHAR 'l'
36+
#define RIGHT_CMD_CHAR 'r'
37+
#define FORWARD_CMD_CHAR 'f'
3538
int wPos,fPos,bPos,cycle,dir,rPos, superCycle,robotspeed;
3639
boolean evitement;
3740
String inText;
@@ -163,29 +166,29 @@ void loop()
163166

164167
// wait for incoming data
165168
if (BT.available() > 0) {
166-
167-
// parse incoming command start flag
168169
get_char = BT.read();
169-
if (get_char == START_CMD_CHAR) {
170-
BT.println("commande recue ");
171-
172-
// parse incoming command type
173-
ard_command = BT.parseInt(); // read the command
174-
170+
if (get_char == SPEED_CMD_CHAR) {
171+
BT.println("speed command ");
172+
ard_command = BT.parseInt();
173+
if (ard_command != 0)
174+
{
175+
robotspeed=(int)ard_command;
176+
BT.println("Speed set to : ");
177+
BT.println(robotspeed);
178+
}
179+
} else if(get_char == LEFT_CMD_CHAR) {
180+
BT.println("left command");
181+
dir=LEFT;
182+
} else if(get_char == RIGHT_CMD_CHAR) {
183+
BT.println("right command");
184+
dir=RIGHT;
185+
} else if(get_char == FORWARD_CMD_CHAR) {
186+
BT.println("FORWARD command");
187+
dir=FORWARD;
175188
}
176189
}
177190

178191

179-
if (ard_command != 0)
180-
{
181-
robotspeed=(int)ard_command;
182-
BT.println("Speed set to : ");
183-
BT.println(robotspeed);
184-
}
185-
186-
187-
188-
189192
if (cycle==5){
190193
// No delay
191194
} else {
@@ -226,6 +229,4 @@ void loop()
226229
evitement = 1;
227230
}
228231

229-
230-
231232
}

0 commit comments

Comments
 (0)