View Single Post
  #10   Spotlight this post!  
Unread 13-02-2008, 08:32
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: Pneumatics coding

Quote:
Originally Posted by Inetta View Post
okay, I understand how it all works now however I'm not sure how I could write a block of coding that would allow me to toggle the buttons.. if that is possible.

Is there a code that would allow me to just press button = active;
press again = inactive?
Well, you need to know some characteristics about these switches.

First off, you will need to probably de-bounce the switches. The chances that you get something like "000000100010101110111111" when the button is pressed are likely. I don't use toggles, so I don't know about code for this. While I could script it up, it would likely be horribly inefficient...

Second, you will need to have a static variable that you set to 1 when the switch is triggered; set it to 0 when the switch goes to 0. Before you set this variable, check if the switch is 1 and the variable is 0; if this condition is true, change the pneumatic, then set the variable to 1.

Let me know if you would like pseudo code, but I'd prefer not to write specific code. That should be left up to you.

JBot
__________________
Aren't signatures a bit outdated?