I am hacking an app that allows users to doodle onto an LCD shield and the get a robot to draw it out using pens.
The robot is a 2 wheel device and to make a turn it has to rotate x degrees.
They press up 4 times, right 6 times they get this:
I fill up an array with the following. m = 1111333333
m = moves 1 = fwd 3 = right
I can then play this back by looping over the array and all seems good. The functions for fwd and right are called in sequence to drive the motors.
Now this is where I become unstuck!
Going fwd is fine, when the bot encounters a right turn it has to rotate 90 degress, ok so far. But the command set is issuing right commands because the LCD was updated in the X axis, so the bot will do 6 right truns.
I need to create some rules that look at the last and current command. So the above example would look like
1111311111 do 4 fwds, 1 right turn, 5 fwds.
I have tried to set a variable that contains the last run command, and getting the current instruction to make a decision based on that. I can't seem to figure out how to create the rule.