Serin command with Eb500 need help.?
Tomvn
Posts: 103
·Hi , I have problem with this code write for boebot· , i use· laptop to control boebot to movment via Eb500 bt , the problem is· like i have push two time on F key so that wil make boebot move , so anyway can i just push one time on F key to make boebot move forward , i like to make simlple movement forward = F , backward = B, Right = R, and Left = L,
here my code . any help thanks.
Tom.vn
here my code . any help thanks.
Tom.vn
Comments
Read up about the WAIT parameter on serin.
You could use any character for the prefix. For example if you use z as the prefix you would have a comand like:
Motion Var Byte
SERIN BT_RX,BTBaud,[noparse][[/noparse]WAIT ("z"), Motion]
If Motion = "f" then forward_fast
If Motion = "b" THEN backward
If Motion = "l" THEN left
If Motion = "r" THEN right
To move the robot, you would type zf and it will go forward, etc.
I'm using a vb program to control a robot with this scheme. The major diffence is the program sets the prefix in the backgroud before sending the command to the robot.
One way around this would be to remember the last valid value sent and if there are no valid values, repeat that action. You also need to remember that SERIN is NOT BUFFERED. So you have to be sending the stop command at the instant the unit is running the SERIN command.
I cheated and added the Servo Controller Board. It has a set it and forget it operation. The BS2 sends it the commands to move forward and it handles sending the pulses to the servos. It will continue sending pulses with the right timing until you tell it to stop. Thus, my BS2 can spend its time waiting for the next command to come in on the SERIN while the servo controller keeps the wheels turning.
SERIN BT_RX,BTBaud,[noparse][[/noparse]WAIT ("!"), Motion]
If Motion = "forward" then forward_fast
or i should sent string value to it, i know serin it not buffered.
make subrountine to reciever each value a time. i will try it tonight.
http://forums.parallax.com/showthread.php?p=754639
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering