View unanswered posts | View active topics It is currently Sun Dec 21, 2014 12:07 am






Reply to topic  [ 3 posts ] 
HELP FAST PLEASE 
Author Message
Rookie

Joined: Wed Feb 08, 2012 8:28 pm
Posts: 13
Post HELP FAST PLEASE
I need a code that makes a action happen after a button is HELD DOWN for 5 SECONDS it has to happen only when the button isheld down for 5 seconds it is for a emergency shut off switch and we need help fast. maybe a while for statement or something please help fast!
Thekid986


Sat Feb 11, 2012 3:07 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: HELP FAST PLEASE
It would have been nice to have more information, but here's how you can do somethings like this:
Code:
void doSomething(){
  //do something
}

task main(){
  while(true){
    if(SensorValue(button) == 1){
      ClearTimer(T1);
      while(SensorValue(button) == 1 && time1[T1] < 5000);
    }
    if(time1[T1] >= 5000){
      doSomething();
    }
  }
}
   

Note that in this code, nothing else can happen while that button has been held down.

_________________
sudo rm -rf /


Sat Feb 11, 2012 3:18 pm
Profile
Rookie

Joined: Wed Feb 08, 2012 8:28 pm
Posts: 13
Post Re: HELP FAST PLEASE
thanks very much that helped a lot


Mon Feb 13, 2012 11:36 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.