Hello,
I'm trying to create a robot controlled by commands through bluetooth from a phone app i made in MIT App Inventor. The commands look like this:
example: "@sc0&"
"@" = routing symbol (routes the command to the correct function)
"sc0" = the command itself (this one is supposed to change speed to 0)
"&" = ending symbol (symbolizes the end of command, intended to fix a bug where the app would send two commands instead of one when two buttons were pressed too quickly, I wasn't able to get it working sadly)
The code should the following way:
void loop is continuously checking if Serial has available data and if it does, it writes it down to the variable InputString, afterwards it adds a NULL character.
it then calls the fucnction "RouteCommand", which checks the routing symbol and routes it to its correct function.
The correct Function then compares the input to the commands saved in PROGMEM and changes global values, which then influence the robot's movement.
But for some reason, whenever i send a command, the program just stops working.
I added a Serial.print to the RouteCommand function, so I can see what the program recieves.
here's what happens:
program turned on
connected through bluetooth, no problems so far
I try to send a command "#0&" which should stop the robot's movement
Serial monitor shows "#0⸮"
I try to send another command
Serial monitor shows "#0⸮⸮"
now whenever I try to send another command it adds a "⸮"
Code attached
What am i doing wrong?
robot_control_system_2.ino (8.73 KB)