Quote:
|
Originally Posted by sirbleedsalot
My team is not finished yet but it seems you guys could help me out, how do i program my robot to have a motor spin counter clockwise when i pull the trigger on the joystick, then released it stops turning the motor, and when i press the thumb button i want the motor to spin clockwise. I am using easyc and i was wondering how to write that code. Please help.
|
if(p1_sw_trig==1)
pwm01=0;
else if(p1_sw_trig==0)
pwm01=127;
if(p1_sw_top==1)
pwm01=255;
else if(p1_sw_top==0)
pwm01=127;
This is how you would do it in mplab...not sure if it will work in easy c.
The "p1's" in the "if's" are dependent on what port your joystick is plugged into in the OI. If your joystick is plugged into port 2- change it to p2_sw_trig.
Also...the ""pwm01" should be changed to whatever pwm your motor is connected to. You should also check if the thumb button is p1_sw_top...it could also be p1_sw_aux1 or p1_sw_aux2.
Please tell me if I confused you and I will try to make it simpler.