Skip to content

Commit 0cb903d

Browse files
uni_hall: Add example
Signed-off-by: Francois Berder <francois.berder@imgtec.com>
1 parent 689af76 commit 0cb903d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

examples/uni_hall_example.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python3
2+
"""This example shows how to use the UNI Hall Click binding of LetMeCreate.
3+
"""
4+
5+
from letmecreate.click import uni_hall
6+
from letmecreate.core.common import MIKROBUS_1
7+
from letmecreate.core.gpio_monitor import GPIO_FALLING, GPIO_RAISING
8+
from time import sleep
9+
10+
11+
def print_hello(arg):
12+
if arg == GPIO_FALLING:
13+
print("Hello, starts dectecting north pole.")
14+
elif arg == GPIO_RAISING:
15+
print("Hello, stops dectecting north pole.")
16+
17+
uni_hall.attach_callback(MIKROBUS_1, print_hello)
18+
print("Callback is now active for 15 seconds.")
19+
print("Move the north pole of a magnet over the sensor to print \"hello\".")
20+
sleep(15)

0 commit comments

Comments
 (0)