|
Re: Relay Programming Questions...
I figured that out...I actually got it to work, but it works once and then not again. I made sure it was resetting the counters.
This is the code i wrote...
This is in the Default_Routine:
if(p1_sw_trig)
{
counter1++;
if(counter1 == 14)
{
shoot_level = 1;
counter1 = 0;
}
}
else if(!p1_sw_trig)
{
counter1 = 0;
}
if(shoot_level > 0)
{
shoot_level_runner();
shoot_level++;
printf("%d\n", shoot_level);
}
if(shoot_level == 61)
{
shoot_level = 0;
counter1 = 0;
}
This is the funtion it calls:
void shoot_level_runner(void)
{
if(shoot_level == 1)
{
relay4_rev = 1; // top ram out
}
if(shoot_level == 20)
{
relay3_fwd = 1; // bottom ram out
}
if(shoot_level == 40)
{
relay3_rev = 1; // bottom ram in
}
if(shoot_level == 60)
{
relay4_fwd = 1; // top ram in
}
}
Why does it only work once???
|