0

Rotary controller not working (Hifiberry OS)

Hello, 

I have been following this thread, I read that the plugin is built into the latest OSs, no need to install it.

Setup:

Raspberry Pi 4
HifiBerry AMP 2
KY040 Rotary Controllers
HifiBerry OS v20210203

I have wired the rotary as follows:

clk = GPIO23 - pin 16
dt = GPIO24 - pin 18
sw = GPIO25 - pin 22
+ = 3.3V - pin 1
gnd = GND - pin 20

My /etc/audiocontrol2.conf has the lines:

[controller:ac2.plugins.control.rotary.Rotary]
clk = 23 #pin16
dt = 24 #pin18
sw = 25 #pin22
step = 5

I am seeing no response from the rotary controller at all.

What is the best way to troubleshoot? Anything I'm missing/doing wrong?

 

The follow code registers activity with my setup:

from time import sleep
from RPi import GPIO

# Pin definitions
clk = 23
dt = 24

GPIO.setmode(GPIO.BCM)
GPIO.setup(clk, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(dt, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

counter = 0
clkLastState = GPIO.input(clk)

print('start')

try:
while True:
clkState = GPIO.input(clk)
dtState = GPIO.input(dt)
if clkState != clkLastState:
if dtState != clkState:
counter += 1
else:
counter -= 1
print (counter)
clkLastState = clkState
sleep(0.01)
finally:
GPIO.cleanup()

 

0 comments

Please sign in to leave a comment.