rc car
hello,
i need to ask for some help with a project
I was needing to use a computer to control an rc car.
so far i have the wiring working.
I just don't know how to program it
i need to ask for some help with a project
I was needing to use a computer to control an rc car.
so far i have the wiring working.
I just don't know how to program it
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
but using the debug terminal as the input
The Microcontroller Application Cookbook (Microcontroller Application Cookbooks) (Paperback)
by Matt Gilliland (Author)
Its a great book that breaks down input/output/control very and makes it very easy because the code examples are very brief. Even better for you, they are written in PBASIC which is your stamp's language. Of special interest to you should be the details on circuit protection.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thomas Talbot, MD
Gunpowder, MD, USA
I tried a code (but did not work) the debug would only accept 02
' {$STAMP BS2}
' {$PBASIC 2.5}
direction VAR Word
DEBUG "enter direction ",CR
DEBUGIN DEC direction
DO
IF (direction = 02) THEN
HIGH 0
HIGH 2
IF (direction = 01) THEN
HIGH 0
HIGH 3
IF (direction = 00) THEN
LOW 0
IF (direction = 1) THEN
HIGH 1
IF (direction = 0) THEN
HIGH 0
IF (direction = 11) THEN
HIGH 1
HIGH 2
IF (direction = 12) THEN
HIGH 1
HIGH 3
PAUSE 1000
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
END
LOOP
Take a look in the Basic Stamp Manual online.
(program still has the problems)
' {$STAMP BS2}
' {$PBASIC 2.5}
direction VAR Word
DO
DEBUG "enter direction ",CR
DEBUGIN DEC direction
IF (direction = 02) THEN
HIGH 0
HIGH 2
ELSEIF ( direction = 03) THEN
HIGH 0
HIGH 3
ELSEIF (direction = 00) THEN
LOW 0
ELSEIF (direction = 1) THEN
HIGH 1
ELSEIF (direction = 0) THEN
HIGH 0
ELSEIF (direction = 11) THEN
HIGH 1
HIGH 2
ELSEIF (direction = 12) THEN
HIGH 1
HIGH 3
PAUSE 1000
DEBUGIN direction : direction =00
ENDIF
END
LOOP
The SELECT-CASE should work for you as well. A common mistake is using the "=" between CASE and the variable
you are evaluating. This is the syntax:
SELECT direction
CASE 0 THEN ' don't use equal sign
HIGH 0
CASE 1 THEN
HIGH 1
.
.
.
ENDSELECT
· Also, your program won't loop because you have an END statement within your loop structure.· Did you mean to end your IF-THEN-ELSEIF structure with this?· You should remove END.
Post Edited (Mikerocontroller) : 11/15/2008 4:00:37 AM GMT
but the program only excepts one direction then has to be reset-any ideas?
' {$STAMP BS2}
' {$PBASIC 2.5}
direction VAR Word
DO
DEBUG "enter direction ",CR
DEBUGIN DEC direction
SELECT direction
CASE 0
HIGH 0
CASE 1
HIGH 1
CASE 2
HIGH 2
CASE 3
HIGH 3
CASE 4
HIGH 4
ENDSELECT
LOOP
Also, the pins will stay·HIGH once you set them.· If your program doesen't change their state they will stay that way.
Don't drive any kind of motor directly from the Stamp pins.
Post Edited (Mikerocontroller) : 11/17/2008 3:16:32 AM GMT
i had used relays
5v .002a