Skip to content

Commit

Permalink
uni_hall: Add example
Browse files Browse the repository at this point in the history
Signed-off-by: Francois Berder <[email protected]>
  • Loading branch information
francois-berder committed Feb 14, 2017
1 parent 689af76 commit 0cb903d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/uni_hall_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python3
"""This example shows how to use the UNI Hall Click binding of LetMeCreate.
"""

from letmecreate.click import uni_hall
from letmecreate.core.common import MIKROBUS_1
from letmecreate.core.gpio_monitor import GPIO_FALLING, GPIO_RAISING
from time import sleep


def print_hello(arg):
if arg == GPIO_FALLING:
print("Hello, starts dectecting north pole.")
elif arg == GPIO_RAISING:
print("Hello, stops dectecting north pole.")

uni_hall.attach_callback(MIKROBUS_1, print_hello)
print("Callback is now active for 15 seconds.")
print("Move the north pole of a magnet over the sensor to print \"hello\".")
sleep(15)

0 comments on commit 0cb903d

Please sign in to comment.