View unanswered posts | View active topics It is currently Sun Nov 19, 2017 4:02 pm






Reply to topic  [ 2 posts ] 
Coding Problems: Making a Counter that Counts by 1 
Author Message
Rookie

Joined: Tue Feb 23, 2016 9:21 am
Posts: 1
Post Coding Problems: Making a Counter that Counts by 1
My team and I have been struggling to write code that uses a limit switch or bump switch. We want the code to make a counter that counts each time the switch is pressed down. However our code counts to roughly 60,000 for every 1 second it is pressed. It counts higher and higher the longer you hold it down. We just want the code to count it when it is pressed and not by how many seconds it was held down for. I do not have the code on my person as it is on my teammate's computer but if anybody could offer tips or guidelines to follow, it would much appreciated. :)


Tue Feb 23, 2016 9:40 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: Coding Problems: Making a Counter that Counts by 1
This is fairly easily solved with some code that waits for the switch to be NOT pressed before continuing, pseudo code:
wait for button to be pressed
wait for button to be released
increment counter

That's all :)

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Wed Feb 24, 2016 3:18 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.