programing a robot and i need help
Archiver
Posts: 46,084
programing a robot my first team at school and i need help tring to
get it to run on only one joy stick instead of 2 their is 2 motors
and they each have one joystick now but im trying toget them both to
work on the same one and if someone will provide me with the code i
will be very greatful
get it to run on only one joy stick instead of 2 their is 2 motors
and they each have one joystick now but im trying toget them both to
work on the same one and if someone will provide me with the code i
will be very greatful
Comments
the code you need, but I think I can give you a general idea.
There are 2 common kinds of joysticks. One uses variable resistors (pots)
and the other uses 4 switches that indicate the direction(s) you are
pushing.
The first kind (sometimes called an analog joystick) can be read with RCTime
(assuming you are using a BS2). You'll need to set thresholds to decide
what's center, left/down, or right/up. The switches are easy since you just
have to see which switches are "on". I'd write a subroutine that just
printed out "Up", "Left", etc. using DEBUG until I got that logic right.
You also need to write subroutines to make your motors spin (servos?) one
way or the other. You also need a routine to make the motors spin in
opposite directions to turn.
So let's say you write: read_joy, motor_fwd, motor_rev, motor_left, and
motor_right.
Now the program almost writes itself:
joydir var byte
top:
gosub read_joy ' sets joydir
if joydir=1 then fwd
if joydir=2 then rev
if joydir=3 then lft
if joydir=4 then rght
' joydir is 0 on center position
' could use a branch to do the above
goto top
fwd:
gosub motor_fwd
goto top
etc.
Hope that helps some. I taught a FIRST team last year and we had a great
time.
Check out the Stamp FAQ at http://www.al-williams.com/wd5gnr/stampfaq.htm
Al Williams
AWC
* Control 8 servos at once: http://www.al-williams.com/awce/pak8.htm
>
Original Message
> From: jerry_k611@h... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=cjy26HBrNVKmwOMExDuzddMAyEySep6wy5kwIeJdl8CM6bLK_bWgJi9cnJjrlkJlLK3k_1qJ1tUoFb4KFZI]jerry_k611@h...[/url
> Sent: Tuesday, November 07, 2000 5:43 PM
> To: basicstamps@egroups.com
> Subject: [noparse][[/noparse]basicstamps] programing a robot and i need help
>
>
> programing a robot my first team at school and i need help tring to
> get it to run on only one joy stick instead of 2 their is 2 motors
> and they each have one joystick now but im trying toget them both to
> work on the same one and if someone will provide me with the code i
> will be very greatful
>
>
>
http://members.tripod.com/~divelec/joystick_progra
m.html for an example of using a single analog
joystick to control 2 motors with a BS2. I've
used it succesfully to control the speed and
direction of 2 motors in one of my robots for the
last year or so. While it is configured for my
particular equipment, it wouldn't take much
tweaking to get you up and running.
You can download it with the download button at
the bottom of the page.
Good luck with your project & don't hesitate to
contact me directly if I can help you over any
humps with the code or whatever.
Carl
Diverse Electronic Services
> >
Original Message
> > From: jerry_k611@h...
[noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=lhtBxSBnSS8jD53l-lntuRDdZuzYkCrgXEKIzyjLCKNJp_LChH92Wh9aP0gg33gyl_6qp_kC_tsbzMEB]jerry_k611@h...[/url
> > Sent: Tuesday, November 07, 2000 5:43 PM
> > To: basicstamps@egroups.com
> > Subject: [noparse][[/noparse]basicstamps] programing a robot and
i need help
> >
> >
> > programing a robot my first team at school
and i need help tring to
> > get it to run on only one joy stick instead
of 2 their is 2 motors
> > and they each have one joystick now but im
trying toget them both to
> > work on the same one and if someone will
provide me with the code i
> > will be very greatful
> >
> >
> >
>
>
>
>
>
________________________________________________
Get your own "800" number - Free
Free voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag
they call it a "Tank Drive". Its very simple.
The company is a supplier to the FIRST competition, but offers H-bridge
relays, and high-current MOSFET PWM speed controllers for other purposes
than a competition robot. They offer complete control systems based on the
Stamp-2SX. High quality, and easy to use, but limited to
proportional and discrete inputs.
http://www.innovationfirst.com/
http://usfirst.org/
Mike Gray
Original Message
From: jerry_k611@h... <jerry_k611@h...>
To: basicstamps@egroups.com <basicstamps@egroups.com>
Date: Tuesday, November 07, 2000 6:46 PM
Subject: [noparse][[/noparse]basicstamps] programing a robot and i need help
>programing a robot my first team at school and i need help tring to
>get it to run on only one joy stick instead of 2 their is 2 motors
>and they each have one joystick now but im trying toget them both to
>work on the same one and if someone will provide me with the code i
>will be very greatful
>
>
>
>