Closed pacm4n1337 closed 2 years ago
I've got this driver working for micropython on the ESP32 and ESP8266.
It would only require small modifications to make it run on "big python" on the Raspberry Pi.
Mainly swapping the i2c
for smbus
and testing.
Are you running micropython or python on your Raspberry Pi 4?
See the interfaces readme in the examples folder. If you are new to this chip, try the list or method interfaces. They are probably the easiest for beginners.
I'll add more examples soon, but for your simple switch on B1 or A1, you just need to define the pin as an input, then read the state of the pins to see if it's pressed. A more advanced version would be to not have to constantly poll the chip asking if anything has been pressed, instead have the chip fire an interrupt when a button is pressed (gpio changes state).
# A0 = mcp[0], A1 = mcp[1], A2 = mcp[2]
# B0 = mcp[8], B1 = mcp[9], B2 = mcp[10]
# set A1 pin as input
mcp[1].input(pullup=1)
# read the pin value - 1 means not pressed, 0 means pressed
while True:
print(mcp[1].value())
Thank you. Got it.
hi, I use a raspberry pi 4 with buster and have a CJMCU-2317 at it. how i get it installed or what are the requirements? Where can i get an example code to switch on B1 or A1 to learn how it works?