Last active
December 25, 2020 21:59
-
-
Save meub/c3833921a3a45a3ec392d9962313b68e to your computer and use it in GitHub Desktop.
Raspberry Pi Bell Ringer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import time | |
import RPi.GPIO as GPIO # Importing the GPIO library | |
from time import sleep # Import sleep module from time library | |
# Set up GPIO | |
servo_pin = 21 # GPIO Pin where servo is connected | |
GPIO.setmode(GPIO.BCM) | |
# Define the Pin numbering type and define Servo Pin as output pin | |
GPIO.setup(servo_pin, GPIO.OUT) | |
p = GPIO.PWM(servo_pin, 50) # PWM channel at 50 Hz frequency | |
p.start(0) # Zero duty cycle initially | |
# Hammer time! | |
sleep(0.4) | |
p.ChangeDutyCycle(6) | |
sleep(0.4) | |
p.ChangeDutyCycle(12) | |
sleep(0.25) | |
p.ChangeDutyCycle(6) | |
sleep(0.4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment