Hardware Reference
In-Depth Information
Prepare for lift off
We will interface the reed switch as shown in the preceding diagram. Let's test it on a
breadboard before seing it up in an enclosure:
Reed switch interfaced to Raspberry Pi
Engage thrusters
1.
We will be tracking whether the key is in the right place by ataching a bar magnet
to the keys. We will set up a GPIO pin as we get started:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.IN)
2.
We will read the inputs and if the magnet in the key is not nearby the reed switch,
we should be able to trigger an alert:
while True:
if(GPIO.input(18)):
print("Keys are in the right place")
else
print("Keys missing!")
 
Search WWH ::




Custom Search