Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Problems programming a switch (http://www.chiefdelphi.com/forums/showthread.php?t=34915)

caderader 18-02-2005 15:19

Problems programming a switch
 
I am trying to make our arm work on a switch(one position is up one for down and one for neutral) so far i have not successfully been able to get the switch to work the arm. At first i thought the code might be similar to the 1 joystick code but its not. We are using a motor like the one that is on the drivetrain to power it. Does anyone know how i could do this.
Thanks!

caderader 18-02-2005 15:49

Re: Problems programming a switch
 
I am trying to get this switch when flipped up to run a pwm at full speed (255?) when flipped to the middle to run it at neutral(127) and when flipped all the way down to run it in full reverse(0) does anyone have idea how i could code this.
Thanks again
Cade

Alan Anderson 18-02-2005 22:06

Re: Problems programming a switch
 
Connect the common of the switch to ground on the OI, the "up" contact to p4_sw_aux1, and the "down" contact to p4_sw_aux2. Assuming the arm motor is on pwm3, your code would look like this:
Code:

    if (p4_sw_aux1 == 1)
      pwm3 = 254;
    else if (p4_sw_aux2 == 1)
      pwm3 = 0;
    else
      pwm3 = 127;



All times are GMT -5. The time now is 04:42.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi