Hello!
So I am currently working on a project that uses the Geeetech voice module, it can have up to 15 commands but you can't actually use 15 commands, it's 3 groups and each group is 5 commands, you can only use 5 commands one at a time (at least that's how I understood it), so I have to use the last command of group 1 to 'enter' group 2 or 3.
Basically, my project makes a robot move forward, backward, turns left, and right. That's 4 commands. I also want to make it do some tricks like spin, and turn on and off an LED as its eyes. That's 3 commands. So in total it's 7 commands + 1 for entering group 2.
This is my code so far. Am I doing this right?
#include <Servo.h>
byte com = 0;
//Servo names
Servo myServoR;
Servo myServoL;
//LED pins
int RightLED = 2;
int LeftLED = 3;
void setup() {
Serial.begin(9600);
myServoR.attach(8); //servo pin right
myServoL.attach(9); //servo pin left
myServoR.write(0); //servo position at 0
myServoL.write(0);
pinMode(RightLED, OUTPUT);
pinMode(LeftLED, OUTPUT);
Serial.write(0xAA);
Serial.write(0x37);
delay(1000);
Serial.write(0xAA);
Serial.write(0x21);
Serial.write(0x22);
}
void loop() {
while(Serial.available()) {
com = Serial.read();
switch(com) {
case 0x11: //command 1 "go straight"
(code for going straight)
break;
case 0x12: //command 2 "go back"
(code for going back)
break;
case 0x13: //command 3 "turn right"
(code for turning right)
break;
case 0x14: //command 4 "turn left"
(code for turning left)
break;
case 0x15: //command 5 enter group 2 "voibot"
Serial.write(0xAA);
Serial.write(0x22);// enter group 2
break;
case 0x16: //command 6 "lights on"
(code for turning on LED)
break;
case 0x17: //command 7 "lights off"
(code for turning off LED)
break;
case 0x18: //command 8 "spin"
(code for spinning)
break;
}
}
}
I need help with figuring out how to enter group 2. Don't really understand what this part do, maybe if I knew, It would give me a hint. Any help would be appreciate it! Thanks
Serial.write(0xAA);
Serial.write(0x37);
delay(1000);
Serial.write(0xAA);
Serial.write(0x21);
Serial.write(0x22);