Skip to content

Instantly share code, notes, and snippets.

@todbot
Last active May 11, 2021 16:11
Show Gist options
  • Save todbot/84e632abf198707506baca5b4d2f0bf8 to your computer and use it in GitHub Desktop.
Save todbot/84e632abf198707506baca5b4d2f0bf8 to your computer and use it in GitHub Desktop.
Play with seesaw encoder knob in CircuitPython
# play with seesaw encoder knob in CircuitPython
import board
from adafruit_seesaw.seesaw import Seesaw
from adafruit_seesaw.neopixel import NeoPixel
from adafruit_seesaw.digitalio import DigitalIO
ss_knob_base_addr = 0x36
ss_switch_pin = 24
ss_neopixel_pin = 6
i2c = board.I2C() # or busio.I2C(pin_scl, pin_sda)
ss_knob = Seesaw(i2c, ss_knob_base_addr)
ss_knob_led = Neopixel(ss, ss_neopixel_pin, 1)
ss_knob_switch = DigitalIO(ss, ss_swtich_pin)
ss_knob_switch.pull = Seesaw.INPUT_PULLUP
# encoder not supported yet
#ss_encoder
while True:
print("switch:",ss_knob_switch.value)
ss_knob_led.fill( int(random.random* 2**24) )
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment