Using Hershey’s Kisses with a Raspberry Pi and Python

 Wire up a button (in this case, two Hershey’s Kisses) and an LED to the Raspberry Pi and write some code to respond to the Hershey’s Kisses when they touch each other. On contact, the LED will light and “on” will be printed in the Python shell. Here’s the Python code:

from gpiozero import LED, Button
from time import time, sleep
led = LED(27)
btn = Button(17)

while True:
    led.off()
    print('off')
    sleep(.5)
    btn.wait_for_press()
    led.on()
    print('on')
    sleep(.5)

Leave a Reply

Your email address will not be published. Required fields are marked *