Contents

Overview

Adafruit's Rotary Encoder is a device that detects rotation. As it rotates, it sends pulses on two pins. By comparing the signals, the direction of rotation can be determined. There are 24 pulses per rotation. The device also acts as a pushbutton switch.

Inputs and Outputs

The device has five pins - three on one side and two on the other. The side with three pins is for the encoder and is ordered (from left to right) signal A, ground, and signal B. The side with two pins is for the pushbutton switch. The signal pins require the use of pullup resistors, and the switch should use either a pullup or pulldown resistor. More information can be found on the product page or on the datasheet.

Bone Usage

The pins on the device can be difficult to use with a bread board, so it may be useful to solder the devide to a perfboard and add connectors.

Rotary encoder with connectors added

What about pullup resistors? The default is for gpio38 (1_6) to be pull up and gpio48 (1_16) to be pull down. Is this intended?

.
The two signal pins and one of the pushbutton pins can be hooked up directly to any of the GPIO ports on the BeagleBone. The pins should then be configured as pullups for the signal pins and either pullup or pulldown for the switch pin. The remaining pins can be hooked up to GND and +3,3v. The example below uses GPIO1_6 for signal A, GPIO1_15 for signal B, and GPIO1_16 for the pushbutton switch.

Rotary encoder hooked up to the BeagleBone

The C code below demonstrates how to use the encoder with the BeagleBone.