ItsyBitsy M0 Express, CircuitPython 3.1.2, and rotaryio

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
DaemonMaker
 
Posts: 14
Joined: Thu Sep 16, 2010 9:32 pm

ItsyBitsy M0 Express, CircuitPython 3.1.2, and rotaryio

Post by DaemonMaker »

I am trying to use a rotary encoder with an ItsyBitsy M0 Express. As per the Rotary Encoder with CircuitPython post by Kattni Rembor I have updated CircuitPython to 3.1.2 and updated the CircuitPython libraries to v3. I have created a simple script that does two things. First, it rotates the onboard dotstar through the rainbow and second, it reads the rotary encoder and prints the encoder.position (see below). While the dotstar functions as expected, turning the rotary encoder does not yield a change in the encoder.position value. Any insight as to why this would be the case would be appreciated.

Code: Select all

import board
import gc
import time
from digitalio import DigitalInOut, Direction, Pull
import adafruit_dotstar
import rotaryio

gc.collect() 

dot = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
encoder = rotaryio.IncrementalEncoder(board.D10, board.D9)

# Helper to give us a nice color swirl
def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if (pos < 0):
        return [0, 0, 0]
    if (pos > 255):
        return [0, 0, 0]
    if (pos < 85):
        return [int(pos * 3), int(255 - (pos*3)), 0]
    elif (pos < 170):
        pos -= 85
        return [int(255 - pos*3), 0, int(pos*3)]
    else:
        pos -= 170
        return [0, int(pos*3), int(255 - pos*3)]


last_position = None
i = 0
while True:
  dot[0] = wheel(i & 255)

  i = (i+1) % 256

  position = encoder.position
  if last_position is None or position != last_position:
    print(position)
  last_position = position

User avatar
adafruit_support_carter
 
Posts: 29150
Joined: Tue Nov 29, 2016 2:45 pm

Re: ItsyBitsy M0 Express, CircuitPython 3.1.2, and rotaryio

Post by adafruit_support_carter »

Let's focus on just the encoder. Does it also not print out if you run the simple example from the guide?
https://learn.adafruit.com/rotary-encoder/circuitpython

If so, post a photo of your setup showing how everything is connected.

DaemonMaker
 
Posts: 14
Joined: Thu Sep 16, 2010 9:32 pm

Re: ItsyBitsy M0 Express, CircuitPython 3.1.2, and rotaryio

Post by DaemonMaker »

That's correct, the simple code from the guide does not work either.

Here a few photos from different angles:
IMG_0392.jpeg
IMG_0392.jpeg (700.38 KiB) Viewed 136 times
IMG_0393.jpeg
IMG_0393.jpeg (724.23 KiB) Viewed 136 times
IMG_0394.jpeg
IMG_0394.jpeg (783.22 KiB) Viewed 136 times

User avatar
adafruit_support_carter
 
Posts: 29150
Joined: Tue Nov 29, 2016 2:45 pm

Re: ItsyBitsy M0 Express, CircuitPython 3.1.2, and rotaryio

Post by adafruit_support_carter »

You need to solder on the header pins. They are not making good electrical contact.

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

Return to “Itsy Bitsy Boards”