The obvious problems have been fixed:
Code:
unsigned char check;
unsigned char topcheck;
\*---------------------------ramp control-------------------------------*/
if (p3_sw_top == 1 && topcheck == 0) // Press top button, kick cylinder extends; press top button cylinder retracts
{
SetRelay ( 2 , 1 ,0 ) ;
topcheck = 1;
}
else if (p3_sw_top == 1 && topcheck == 1)
{
SetRelay ( 2 , 0 ,1 ) ;
topcheck = 0;
}
if (p3_sw_trig == 1 && check == 0) // Press trigger... Hippo folds down and ramp folds out; Press again, reset.
{
SetRelay ( 3 , 1 ,0 );
SetRelay ( 4 , 0 , 1 );
SetRelay ( 5 , 1 ) ;
check = 1;
}
else if (p3_sw_trig == 1 && check == 1)
{
SetRelay ( 3 , 0 ,1 ) ;
SetRelay ( 4 , 1 , 0 );
SetRelay ( 5 , 0 ) ;
check = 0;
}
/*----------------------------Arm control------------------------------------*/
if (p4_sw_aux1 == 1) // if top red switch is up, Hippo is up and Jaw is closed
{
SetRelay ( 4 , 1 , 0 ) ;
SetRelay ( 5 , 1 );
}
if (p4_sw_aux1 == 0) // if top red switch is down, Hippo is down and Jaw is open
{
SetRelay ( 4 , 0 , 1 ) ;
SetRelay ( 5 , 0 );
}
if (p4_sw_aux2 == 1) // if bottom red switch is up, Hippo is down and Jaw is closed (ramp down)
{
SetRelay ( 4 , 0 , 1 ) ;
SetRelay ( 5 , 1 );
}
/*-------------------------Shifting-------------------------------------------*/
if (p4_sw_top == 0 && p3_sw_trig == 0) // if shifter is in Bottom position, servos are in position 1
{
pwm05=0;
}
if (p4_sw_top == 1 && p3_sw_trig == 0) // if shifter is in Middle position, servos are in position 2
{
pwm05=127;
}
if (p4_sw_top == 1 && p3_sw_trig == 1) // if shifter is in Top position, servos are in position 3
{
pwm05=255;
}
I haven't seen a "setRelay" function before, so I can't help you there.