|
Re: A few questions on programming the Control System
Quote:
|
Originally Posted by Avarik
Alright, I finally figured it out! Here is how I did it.
Code:
if (p1_sw_trig && rel1==0)
{
rel1++;
if (rel2==0)
{
relay1_fwd=1;
rel2++;
}
else
{
relay1_rev=1;
rel2--;
}
}
if (!p1_sw_trig)
{
rel1=0;
relay1_fwd=0;
relay1_rev=0;
}
rel1 and rel2 are simply declared as ints, where rel1 is initialized to 0, and rel2 to 1. This makes it go forward at first, then backwards the next time.
|
Essentially my method. 
__________________
Mentor to Teams 555, 1929, and 2070!
Currently working in hardware design at Cisco.
Cornell University DARPA Urban Challenge - http://www.cornellracing.com
Co-Captain Team 555 - 2003,2004,2005
Trust, Love, and Magic
|