Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
A button is a simple input component which responds to being pushed by a user.
1
vote
Accepted
Two buttons, one LCD
buttonState = digitalRead(buttonPin[x]);
Also, what you high likely want to add is button debouncing (check the arduino example about this), unless you add a delay after showing a screen of a considerable …
0
votes
Accepted
How to (optimally) fetch a button press?
You should use the millis function (see millis).
Create a variable of type unsigned long and check it against the current time, with some offset.
See also the debouncing example, how to use this f …
0
votes
How do I modify the value of a variable when I press a switch
First I would make create an enumeration type and motor direction variable (instead of the button state):
enum EMotorDirection
{
CLOCK_WISE,
COUNTER_CLOCK_WISE
}
EMotorDirection _motorDirection … = CLOCK_WISE;
Then read the button and when it has changed (make a variable `_previousButtonState), adjust the motor direction.
int _previousButtonState = LOW;
In the loop function:
int buttonState …
1
vote
Button and switch to turn on and off LED and changing after time
I have to make an answer, since I cannot use items/links easily in a comment.
Instead of creating the application for you, I suggest you do the following:
Read/try and experiment with the default A …
0
votes
Comparing button presses to correct sequence
When you press a button, there is somehwere between fully pressed and not pressed (or backwards) a state there it 'bounces', e.g. you get lots of state transitions, resulting in seeing a button pressed …
0
votes
changing state of an LED using a pushbutton leads to unstable result
This is a comment (but could not use text alignment in a comment):
Instead of
if (flag){
digitalWrite(ledPin13, LOW);
} else {
digitalWrite(ledPin13, HIGH);
}
You can use:
digitalWrite(ledPi …
2
votes
Accepted
Press one button then another?
enum EState
{
// Button 1 and 2 are not pressed
NoButtonsPressed,
// Button 1 is pressed, button 2 is not pressed
FirstButtonPressed,
// Both buttons are pressed
BothButtonsPressed
};
EState … 1 is still pressed, ignore second button.
}
else if (digitalRead(2) == HIGH)
{
// Button 1 is not pressed, button 2 is pressed. …
4
votes
Arduino Timer with increase time button
When using a button (you already put it in a variable), just remove 10 seconds, and update the time. … However, check also the Blink Without Delay example on the Arduino website, since when you press a button, high likely the button will bounce and one press may result in several times 10 seconds will be …
2
votes
What is the best technique to design a 20 push button circuit
With one of such IC you can connect 8 buttons, however you can daisy chain max 4 to get 4 * 8 = 32 button inputs, only using 4 digital pins of the Arduino. … In your case you would need 3 ICs to get 24 (thus 20) button inputs. …
1
vote
using a switch case with a 5-position switch and serial output
For the button states:
int buttonState1 = 0; // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int buttonState5 = 0;
you can use
boolean buttonStates … To read the button states:
buttonState1 = digitalRead(buttonPin1) == 2;
buttonState2 = digitalRead(buttonPin2) == 3;
buttonState3 = digitalRead(buttonPin3) == 4;
buttonState4 = digitalRead(buttonPin4) …
1
vote
Accepted
RGB LED Mode toggle - Trying to avoid using main loop()
This is caused by button bouncing. When you press a button, for a short time, the contact is somewhere between on and off. … To prevent this, use button debouncing (check the Arduino site for a Button Debounce example). …
0
votes
How can I add a potentiometer and more buttons to my custom game controller?
It seems pins 11, 12 and 13 do not exist as input pins and pins 0 and 1 are used for RX/TX which you don't want to use neither probably.
So instead of using a for loop iterating over indices, you shou …