Pages: [1]   Go Down
Author Topic: Rotary Encoders, button press. Help Needed  (Read 342 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Canada
Offline Offline
God Member
*****
Karma: 7
Posts: 600
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Facts just don't care if you ignore them.

0
Online Online
Shannon Member
****
Karma: 200
Posts: 11712
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: