Quote:
|
Originally Posted by Avarik
Firstly, how would I set up a system to push 1 button to open and close pneumatics? I was thinking about having a state which is altered if the button is pushed, but I cannot figrure out how to do this (from decleration to initialization to writing the code!)
|
There could be another (better) way but the way I did it last year (now in C) would be as follows:
Code:
bool pressed=false; //is switch pressed (put this somewhere where it will remain globally constant)
if(p1_sw_top&&!pressed)
{
pressed=true;//set the toggle value
relay1_fwd=(!relay1_fwd);//set the relay state
}
else if(p1_sw_top)
{
//do something else if you want (but you don't have to)
}
else
{
pressed=false;//turn off the toggle
}
Quote:
|
Originally Posted by Avarik
Secondly, how do I create a program which will overide all other code and execute a set of commands? This would be to use pneumatics to shift gears in a gearbox. I am unsure how to program the code, and set up overiding the system. I was thinking about using interupts, but I don't know how to call them (I have Kevin's code with the interupts added in.)
|
I'm not exactly sure what you need but you can use an
if statement to check for a certain state and call functions you create (run_drive_code() and run_override_code() for example) based on the state. That would probably be the easiest method unless you need multiple override options in which case a
switch statement would probably be useful.
__________________
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