methods?
CodeGuru
Posts: 2
I take Computer science in school and we work with Java.
Well what I am wondering about is can you make and recall back to methods?
Like you have a method to make a left turn, you know just so you don't have repetitive code.
Anyone know?
Well what I am wondering about is can you make and recall back to methods?
Like you have a method to make a left turn, you know just so you don't have repetitive code.
Anyone know?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Now I ran into a new problem...
I made this code while also looking in the manual, and the code looks great.
"Left:
FOR counter = 0 TO 70
PULSOUT 12, 750 - counter
PULSOUT 13, 750 - counter
NEXT
FOR counter = 70 TO 0
PULSOUT 12, 750 - counter
PULSOUT 13, 750 - counter
NEXT
PAUSE 100
RETURN
Right:
FOR counter = 0 TO 70
PULSOUT 12, 750 + counter
PULSOUT 13, 750 + counter
NEXT
FOR counter = 70 TO 0
PULSOUT 12, 750 + counter
PULSOUT 13, 750 + counter
NEXT
PAUSE 100
RETURN
Forward:
FOR counter = 0 TO 100
PULSOUT 12, 750 - counter
PULSOUT 13, 750 + counter
NEXT
FOR counter = 1 TO 100
PULSOUT 12, 650
PULSOUT 13, 850
NEXT
FOR counter = 100 TO 0
PULSOUT 12, 750 - counter
PULSOUT 13, 750 + counter
NEXT
PAUSE 100
RETURN"
The Problem is that the left turn works fine; the servos turn and stop when told. But the forward and Right do a big jerk at the end (like they go in reverse for a split second)
I don’t know why this is happening, because the code for left and right are exactly the same besides a few "+"s and "-"s.
Any one else have this problem?
You need to put "PAUSE 20" inside each of your FOR...NEXT loops.
Like this:
FOR counter = 0 TO 70
PULSOUT 12, 750 - counter
PULSOUT 13, 750 - counter
PAUSE 20
NEXT
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
"Save your money. Pay with cash."
·