Hello,
I need some beginner help.
I bought this button Recommendations For You - DealeXtreme
All the examples I see online have a simple button that is connected with just 2 pins. This one has 3.
I connected it up like this.
G => Ground
V => arduino 5v
S => arduino pin set to input.
My input pin is always low.
For the code below I only get a 0.
I would like to connect this up to an interrupt but I can't get any signal from it.
Can someone help me out or point me to a tutorial?
Thanks
int pin = 26;
void setup()
{
Serial.begin(9600);
pinMode(pin, INPUT);
}
void loop()
{
Serial.println("button");
int buttonState = digitalRead(pin);
Serial.println(buttonState);
delay(1000);
}
huenemeca:
Hello,
I need some beginner help.
I bought this button Recommendations For You - DealeXtreme
All the examples I see online have a simple button that is connected with just 2 pins. This one has 3.
I connected it up like this.
G => Ground
V => arduino 5v
V doesn't appear to be connected to anything on the switch. Disconnect it.
S => arduino pin set to input.
Add a 10k resistor between the pin and +5V.
I am sorry I am a little confused. You said to remove the connect from +5v to the V.
Then you said to put a 10k resister between the pin and +5v.
So I would have
G => arduino ground.
V => nothing
S => I am not sure about. The pin is input so where is the +5v connected to?
Hello....Can you clarify what you get when the button is not pressed and when the button is pressed??
In my current setup I get 0 on the digitalRead pressed and not pressed.
system
6
Ignore the V connection. Looking at the pictures it's not connected to anything at all. My guess is they have one PCB for multiple uses. So ignore V.
Just use G and S. It doesn't matter which is which, it's just a switch. Then use it exactly like any other pushbutton.
Simplest way: connect it between input pin and ground, and enable INPUT_PULLUP on the pin
void setup() {
pinMode(2, INPUT_PULLUP);
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, !digitalRead(2));
}
Thanks, I understand now and am getting it working.