i need to write a prgram that rotates the servo
i need to write a prgram that roates a servo using the debug terminal. the user must enter a number roattion value. the program below is for a user to hit a push button so the servo can turn 45 degrees from zero and turn back from 45 to zero by pressing the other push button i dont know if it works becuase i dont have stamp to test it any help greatly appreciate
this is what i have so far
' What's a Microcontroller - ServoCenter.bs2
' rotate the servo using the debug widow.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!", CR
DEBUG "press button in3",CR
DO
LOOP UNTIL IN3 = 1 AND IN4 = 0
PULSOUT 14, 500
STOP
DEBUG "press in4 to return to zero 0",CR
DO
LOOP UNTIL IN3 = 0 AND IN4 = 1
PULSOUT 14, 250
STOP
this is what i have so far
' What's a Microcontroller - ServoCenter.bs2
' rotate the servo using the debug widow.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!", CR
DEBUG "press button in3",CR
DO
LOOP UNTIL IN3 = 1 AND IN4 = 0
PULSOUT 14, 500
STOP
DEBUG "press in4 to return to zero 0",CR
DO
LOOP UNTIL IN3 = 0 AND IN4 = 1
PULSOUT 14, 250
STOP
Comments
Also, you might want to post this question in the Basic Stamp forum so you get a better chance of getting an answer.
i posted it in code forum i dont want to repost in basic stamp because it will be a double post unless a mod can move it
thanks
Although it would have been better to post this originally in the Stamp forum, it's a general enough discussion of servos to leave here.
is there another way of doing this ?
yourself of the suggested reading list and that's the best
way to get nowhere fast.
It's necessary knowledge, your "background in r/c" notwithstanding.
if you dont belive that i have a background in r/c heres my youtube page http://www.youtube.com/user/wirelesscps?feature=mhum
If I were a gambling man I would bet that axial28rr has not read chapter 4 in "What's a Microcontroller?".
The first DO...LOOP is entered, a pulse is sent, wait 20ms,and execution stops. The servo might twitch a bit depending on it's current angular position.
but i dont want it to power down thats why i used stop instead of end until the last command is excuted
-in3 is pushed moves to 45
-in4 is pushed moves back to 0
PE -- Therefore BS2 PULSOUT range 500-1000?
PE - Surely one with an extensive background in r/c would have been on top of this?
I don't have a youtube channel of me playing with r/c cars, but I can make a BS2 position a servo to 0, 45, 90 deg.
i don't fully understand the DO / LOOP because am new to this if i did understand i wouldent be asking?
Your code
Your code will execute DEBUG, DEBUG, DO, PULSOUT, PAUSE, then STOP... it will never loop back to the DO. It will not execute any of the following DO...LOOPS... ever.
Please don't take this the wrong way but it's very hard to believe, in a forum setting, that you have read any of the suggested materials. One, because in chapter 4 of WAM there are detailed explanations with source code that is directly related to what you're trying to accomplish.
Since you brought it up, please regale the community in the tweaking of Hitec vs Parallax (not paralax) servos.
If you want to learn about servos, read some Wikipedia articles on the subject. If you want to learn about DO / LOOP statements, go through the introductory tutorials like "What's a Microcontroller?". Parallax staff have spent a lot of time putting together these tutorials. They're good at what they do. If, after you've gone through the tutorials and worked through the examples, you still don't understand, ask. Ask if you don't understand specific bits of the tutorials and say what those are.
http://www.youtube.com/watch?v=E856jJRtF2s