![]() |
Help! Programming question with triggers
its the day before competition and i really need help on this. Our team decided to make a trigger box for our robot and one trigger controls 2 motors. What i what it to do is, when i hold the trigger forward, the motors go forward, and when i let go the motor stops. For some reason i cant get it to work. What happens is, i hold the trigger forward and the motors continuely move even if i let go. Ive tried IF loops as well as FOR loops. Any suggestions? (as quickly as possible :ahh: )
|
Re: Help! Programming question with triggers
how do you have it wired up? From what you posted, it sounds like some sort of toggle switch you're using. Do you know what variables that coresponds to in the code?
|
Re: Help! Programming question with triggers
See if u can post a copy of your code. I would stay away from FOR loops, all u should need to do is set the motors to something when ur trigger is forward, and set them to 127 when it is not. Also, see if you have any other code that assigns values to these motors.
|
Re: Help! Programming question with triggers
you dont need an if statement
just something like relay_fwd01 = p1_trig01; in your code when the switch is on the relay is on, when its off, the relay goes off |
Re: Help! Programming question with triggers
Quote:
Code:
pwm01=p1_sw_trig*127+127; |
Re: Help! Programming question with triggers
If they are on PWMs, do something like:
Code:
if(switch == 1){ |
Re: Help! Programming question with triggers
i did mine like this
Code:
pwm03 = 127; /*goal claw up and down*/ |
Re: Help! Programming question with triggers
hmm this is how i originally did it...but it doesnt work. What happens is when i click the trigger, its constantly going forward even when i let go.
Code:
if (p3_sw_trig==1) |
Re: Help! Programming question with triggers
Code:
if (p3_sw_trig==1) |
Re: Help! Programming question with triggers
i forgot to say...it is a self centering toggle switch. Toggle forward is wired up to "trigger", and toggle back is wired up to "top" in code.
Anyways... Slimbojones when i was debugging my code, i tried something like that... and it didnt work. What happens is the 1 from p3_sw_trig is held in the code, so it never goes back to 0 and that means itll never go to neutral. |
Re: Help! Programming question with triggers
Quote:
One question I have: What happens when you push the toggle switch down? Do your motors actually run in reverse then? Or is forward the only direction that's working at all for you? |
Re: Help! Programming question with triggers
Quote:
|
Re: Help! Programming question with triggers
when i pull the toggle switch back...the motors do run in reverse...but again they do not stop even when i let go.
|
Re: Help! Programming question with triggers
Quote:
|
Re: Help! Programming question with triggers
Quote:
|
| All times are GMT -5. The time now is 12:01. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi