hall.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import time
4 
5 import pigpio
6 
7 #
8 # OH3144E or equivalent Hall effect sensor
9 #
10 # Pin 1 - 5V
11 # Pin 2 - Ground
12 # Pin 3 - gpio (here P1-8, gpio 14, TXD is used)
13 #
14 # The internal gpio pull-up is enabled so that the sensor
15 # normally reads high. It reads low when a magnet is close.
16 #
17 
18 HALL=14
19 
20 pi = pigpio.pi() # connect to local Pi
21 
22 pi.set_mode(HALL, pigpio.INPUT)
23 pi.set_pull_up_down(HALL, pigpio.PUD_UP)
24 
25 start = time.time()
26 
27 while (time.time() - start) < 60:
28  print("Hall = {}".format(pi.read(HALL)))
29  time.sleep(0.2)
30 
31 pi.stop()
32 


cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Tue Oct 20 2020 03:35:57