From 0cb903d0aa64cb8af9f4c3eaeec0cfe56543ba99 Mon Sep 17 00:00:00 2001 From: Francois Berder Date: Tue, 14 Feb 2017 10:46:18 +0000 Subject: [PATCH] uni_hall: Add example Signed-off-by: Francois Berder --- examples/uni_hall_example.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 examples/uni_hall_example.py diff --git a/examples/uni_hall_example.py b/examples/uni_hall_example.py new file mode 100755 index 0000000..8b2c910 --- /dev/null +++ b/examples/uni_hall_example.py @@ -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)