a library for raspberry pi gpio extend using aw9523b
Project description
Example
Input
from AW9523B import EX_GPIO,Port0,Port1
fiveWaySwitch = [Port1.PIN7, Port1.PIN6, Port1.PIN5, Port1.PIN4,
Port0.PIN7, Port1.PIN0, Port1.PIN1, Port1.PIN2, Port1.PIN3, Port0.PIN0]
key = ["A2", "B2", "C2", "OK2", "D2", "A1", "OK1", "B1", "C1", "D1"]
for pin in fiveWaySwitch:
EX_GPIO.setup(pin, EX_GPIO.INPUT)
if __name__ == "__main__":
import time
import RPi.GPIO as GPIO
def my_callback(channel):
pin = EX_GPIO.readInput()
if pin:
# print("my_callback",pin)
for x in range(len(fiveWaySwitch)):
if fiveWaySwitch[x] is pin:
print("key:", key[x])
break
aw9523Int = 27
GPIO.setmode(GPIO.BCM)
GPIO.setup(aw9523Int, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.add_event_detect(aw9523Int, GPIO.FALLING, callback=my_callback)
EX_GPIO.readInput()
while 1:
try:
time.sleep(1)
except KeyboardInterrupt as e:
GPIO.cleanup()
break
OUTPUT
from AW9523B import EX_GPIO,Port0
import time
led1 = Port0.PIN5
led2 = Port0.PIN6
EX_GPIO.setup(led1, EX_GPIO.OUTPUT)
EX_GPIO.setup(led2, EX_GPIO.OUTPUT)
if __name__ == "__main__":
while 1:
time.sleep(5)
EX_GPIO.output(led1,EX_GPIO.HIGH)
EX_GPIO.output(led2,EX_GPIO.LOW)
time.sleep(5)
EX_GPIO.output(led1,EX_GPIO.LOW)
EX_GPIO.output(led2,EX_GPIO.HIGH)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aw9523b-1.1.0.tar.gz
(3.0 kB
view details)
Built Distribution
File details
Details for the file aw9523b-1.1.0.tar.gz
.
File metadata
- Download URL: aw9523b-1.1.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2653a750c52272e7caf08556ac5b441409cfdad1efc4ca830f09db0c7555504 |
|
MD5 | 0a99e778d4cd4281ade727bbb7e1e210 |
|
BLAKE2b-256 | 1f55d25d32630ee88192615eead03a5cd1a70abbd5138feb23456090e39a2317 |
File details
Details for the file aw9523b-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: aw9523b-1.1.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b17e2f62e50690038d516489dccda78c6abc2973eb566a9e9a0fdecd6f974db8 |
|
MD5 | 062f8bc5f11edaa5600c16e4ee7cab84 |
|
BLAKE2b-256 | eb6b28706659b1dc1e82c27235c86d3842ac6c330eda51efb8ad50616005fb9d |