View Single Post
  #9   Spotlight this post!  
Unread 10-02-2004, 10:59
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Mapping Buttons to PWMs

Quote:
Originally Posted by Joe Ross
If you want to skip the if statement, you can use the following code

pwm03 = 127 + 63 * p1_sw_trig;

If you want your motor to be able to go backwards also, you can use 2 switches with the following code.

pwm03 = 127 + (63 * p1_sw_trig) - (63 * p1_sw_top);
just a cautionary real-world note, although this may work for the FRC, in actual C, the value of "true" for booleans is not always 1 - in fact, it's often -1.

but yes, for the FRC, one could use Joe's code.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)