View Single Post
  #3   Spotlight this post!  
Unread 25-02-2004, 10:42
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,801
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Using a switch to control a PWM

Quote:
Originally Posted by maxlobovsky
if(p1_sw_some_switch == 1){
pwmxxx=some_value
}

if(p1_sw_some_other_switch == 1) {
pwmxxx=some_other_value
You have the general idea, however, the joystick buttons have a value of "0" by default, and switch to "1" when pressed. You may be confusing your test by having the later switch override the first switch test.
Try a simpler test like:
Code:
if (p2_sw_trig)
pwmxxx = 254;
else
pwmxxx = 0;
The 7.2v backup battery powers the PWM center pin.

[edit] Joe Ross beat me to an answer. Hey, Ken W. my typing must be slowing down!

[edit 2] deltacoder corrected my reversal of the joystick button values. (I also get left and right confused). Thanks delta!
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 25-02-2004 at 14:22.