Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

6
Help with triggering actions using buttonpresscounter
Post Body

I have a project that I need help figuring out how to make a buttonpresscounter trigger certain actions once the counter reaches a predetermined count and then resetting once it gets past a number.

example of what I need:

button count = 0 - LED 1&2 off
button count = 1 - LED 1 on; 2 off
button count = 2 - LED 1 off; 2 on
<counter resets after 2>

example of what I thought it would be:

buttonState = digitalRead(stbyin);
if (buttonState == HIGH) {
count  ;
if (count>=2) {
count = 0;
} else {
(buttonState == LOW);

}

buttonState = digitalRead(stbyin);

if (count == 0); {
digitalWrite(stby, LOW);
digitalWrite(go, LOW);
}
if (count == 1); {
digitalWrite(stby, HIGH);
digitalWrite(go, LOW);
}
if (count == 2); {
digitalWrite(stby, LOW);
digitalWrite(go, HIGH);

}

But what's happening there is whenever I press the button that should trigger the counting, it triggers the whole string to happen at once. I can't find much documentation about this and would really like some help.

Author
Account Strength
100%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
27,400
Link Karma
8,271
Comment Karma
14,734
Profile updated: 3 days ago
Posts updated: 9 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
8 years ago