View Single Post
  #14   Spotlight this post!  
Unread 31-05-2007, 18:21
IraJason IraJason is offline
In Search of "Bang Head Here" Sign
AKA: Ira Goldberg
FRC #3632 (D-Tecs); FRC #1712 (Dawgma)
Team Role: Mentor
 
Join Date: Nov 2005
Rookie Year: 2005
Location: Lower Merion, PA
Posts: 283
IraJason has a brilliant futureIraJason has a brilliant futureIraJason has a brilliant futureIraJason has a brilliant futureIraJason has a brilliant futureIraJason has a brilliant futureIraJason has a brilliant futureIraJason has a brilliant futureIraJason has a brilliant futureIraJason has a brilliant futureIraJason has a brilliant future
Send a message via AIM to IraJason Send a message via MSN to IraJason
Re: Single Click On/Off Using the Trigger in EasyC

Ok, I got the code to work, bit it took a little bit of tweaking. It may be how I set it up though. Either way, I'm able to have the cathodes toggle on and off with the trigger. This is the code I used:

Code:
if(p1_sw_trig && toggle_state == 0)
{
   toggle = !toggle;
}

delay(100);

toggle_state = p1_sw_trig;

if(toggle == 1)
{
   OItoRelay(1,1,1,1)
}
For some reason, without the delay, the program would have the light stay on only when the trigger was held, then not do anything on the second click. On the third click however, the cathodes would stay on after the trigger was pressed. I think it has to do with the amount of time you hold the button down, but I'm not entirely sure. If someone does have an answer to that, it would be greatly apprciated to know for future projects. And again, thank you to all who contributed to this! Doing beginners programming on a computer is a bit different than programming for a real world object.
__________________
Many respectable physicists said that they weren't going to stand for this - partly because it was a debasement of science, but mostly because they didn't get invited to those sort of parties."
-Douglas Adams The Hitchhiker's Guide to the Galaxy

2007 Galileo #6 seed, 5th Alliance Captain, Semi-finalist
2007 Philly Regional #4 Seed, Philly Regional GM Industrial Design Award Winner
2006 Philly Regional Highest Rookie Seed,Philly Regional Rookie All Star