Adafruit_Learning_System_Gu.../Rotary_Encoder/rotary_encoder/code.py
2022-02-18 17:22:12 -05:00

14 lines
369 B
Python
Executable file

# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import rotaryio
import board
encoder = rotaryio.IncrementalEncoder(board.D10, board.D9)
last_position = None
while True:
position = encoder.position
if last_position is None or position != last_position:
print(position)
last_position = position