I got my first robot working with bluetooth motion control which is great but I would like to be able to switch between motion control and autonomous movement. Preferably I would have it switch with the push of a button, such as p.
I can get it to switch over if I use just a variable to change over. For example if I make a variable called autonomous and set it to true every time I call the moveStop function then it switch's to object avoidance but if I change it to something like incomingByte = Serial.read(); and have an if (incomingByte = '112') 112 being what p comes across as then it wont work at all.
I know incomingByte = Serial.read(); works because when I have my WASD/Obstacle avoidance loaded you can move the bot using WASD and switch it to Obstacle avoidance, just fine.
I've tried setting it 2 ways one where the ObjAve is in the same function as the motion control and one where it is separate. I seem to be able to actually send serial data when its in its own function but it jumps right back out.
Please see attached code. Any advice will be greatly appreciated.
2 function method: https://www.dropbox.com/s/qoc3ytb2f6vef05/OwnFunction.txt Single function method: https://www.dropbox.com/s/7wo363hjoxl5kz8/SingleFunction.txt