Ano Directional Wheel on a Raspberry Pico

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
kitwo
 
Posts: 1
Joined: Tue Oct 23, 2018 2:15 am

Ano Directional Wheel on a Raspberry Pico

Post by kitwo »

Hi All, I was hoping someone could help me, I picked up the Ano Directional Navigation and scroll wheel, and am trying to get the wheel/rotary encoder working with the Raspberry Pi Pico
The excellent tutorial: https://blog.adafruit.com/2021/10/06/ne ... -adafruit/

So I've flashed circuit python on my pico, soldered the ano scroll wheel to my pico, on GPIO 6 and GPIO 5, and updated the circuitpython to reflect that:
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""
CircuitPython ANO Rotary Encoder and NeoPixel Ring example.
"""
import board
import digitalio
import rotaryio
import time

# The pin assignments for the breakout pins. Update this is you are not using a Feather.
ENCA = board.GP6
ENCB = board.GP5
#COMA = board.D11
SW1 = board.GP4
SW2 = board.GP3
SW3 = board.GP1
SW4 = board.GP2
SW5 = board.GP0
#COMB = board.SDA

# Rotary encoder setup
encoder = rotaryio.IncrementalEncoder(ENCA, ENCB)
last_position = None


# Button pin setup
button_pins = (SW1, SW2, SW3, SW4, SW5)
buttons = []
for button_pin in button_pins:
pin = digitalio.DigitalInOut(button_pin)
pin.switch_to_input(digitalio.Pull.UP)
buttons.append(pin)

while True:
position = encoder.position
if last_position is None or position != last_position:
print("Position: {}".format(position))
last_position = position
time.sleep(0.5)


if not buttons[0].value:
print("Center button!")
time.sleep(0.5)

if not buttons[1].value:
print("Up button!")
time.sleep(0.5)


if not buttons[2].value:
print("Left button!")
time.sleep(0.5)


if not buttons[3].value:
print("Down button!")
time.sleep(0.5)


if not buttons[4].value:
print("Right button!")
time.sleep(0.5)
time.sleep(0.5)

`
although the other buttons work, the rotary encoder doesn't work, does anyone have any suggestions on what I need to do to get this to work with the raspberry pico?

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Ano Directional Wheel on a Raspberry Pico

Post by mikeysklar »

Do COMA/COMB need to be defined even if being wired to GND? Obviously they would not need the code to pull them low in if they are wired low, but it is not clear to from the example if they can just be commented out.

I did see a mention an obscure issue with the Pico and rotary encoders. The suggestion was not to put directional pins on the same PWM channels which can cause an issue. eg. Space your pin selection between different PWM channels.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”