Go Down

Topic: Rotary Encoders, button press. Help Needed (Read 397 times) previous topic - next topic

Marvell-kid

Hi, I have been playing with arduino for a few months now, and have come to a point in my project where I need some help.
I am trying to use the button press function for my Sparkfun Rotary Encoders. Currently I am using the following code to count the rotations,
http://www.circuitsathome.com/mcu/programming/reading-rotary-encoder-on-arduino
but It doesn't specify how to use the button. It is currently wired up with one of the pins connected to ground and the other to digital pin 12, as shown in this example (not using arduino),
http://www.pavius.net/2010/02/rotary-encoder-based-cooking-timer/

Do I need to re-wire that side of the encoder so that I can use it like a button as shown in the learning area of the arduino site.
http://arduino.cc/en/Tutorial/Button

any help will be greatly appreciated.
Thanks

BillO

If you are counting rotations fine, leave that part alone.  Do not re-wire the 3 pin side of the encoder.

The button can be connected in either way depending on what you want to do with it.  So, what do you want to do with the button press?
Facts just don't care if you ignore them.

MarkT

Just enable the internal pull-up on pin12 and you'll be able to digitalRead() it.  It'll read LOW when the button is pressed.
[ I won't respond to messages, use the forum please ]

Marvell-kid

Hi and thanks for your answers.
I want to be able to use it to count each press, but currently, it won't work with and of the learning examples.
Can anyone, show me exactly what I will need to do.
If I can get it to flash LED on the board I can do the rest, it's just getting the button to work.

As it is connected currently, (GND and PIN12) when ever I touch the metal chassis, the LED lights up, this makes me feel I have wired it up wrong. This using the learning button example.

Go Up