Raspberry Pi Workshop Kit Tutorials – 6 SOS Buzzer
Welcome to the Raspberry Pi Workshop Tutorials, brought to you by ModMyPi, BuyaPi.ca, and PiShop.us. In this series, we’ll demonstrate nine projects that can be made using the YouTube Workshop Kit for Raspberry Pi. These projects are a great way to familiarize yourself with the Pi’s input and output functions, as well as creating programs in Python that we’ll use to control the Pi’s hardware. Tutorial 6 - SOS Buzzer Circuit Diagram: http://www.modmypi.com/download/led_button_buzzer_bb.png Tutorial 6 Download: http://www.modmypi.com/download/youtube_workshop_6_morsecode.pdf View Tutorial Online: https://www.modmypi.com/blog/youtube-workshop-kit/gpio-and-python-69-buzzer *** Code Used In This Tutorial *** NOTE that the third last line needs an edit; replace {greater than} with the corresponding symbol. #!/usr/bin/python import os from time import sleep import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(22,GPIO.OUT) loop_count = 0 # define a function called morsecode def morsecode (): #Dot Dot Dot GPIO.output(22,GPIO.HIGH) sleep(.1) GPIO.output(22,GPIO.LOW) sleep(.1) GPIO.output(22,GPIO.HIGH) sleep(.1) GPIO.output(22,GPIO.LOW) sleep(.1) GPIO.output(22,GPIO.HIGH) sleep(.1) #Dash Dash Dash GPIO.output(22,GPIO.LOW) sleep(.2) GPIO.output(22,GPIO.HIGH) sleep(.2) GPIO.output(22,GPIO.LOW) sleep(.2) GPIO.output(22,GPIO.HIGH) sleep(.2) GPIO.output(22,GPIO.LOW) sleep(.2) GPIO.output(22,GPIO.HIGH) sleep(.2) GPIO.output(22,GPIO.LOW) sleep(.2) #Dot Dot Dot GPIO.output(22,GPIO.HIGH) sleep(.1) GPIO.output(22,GPIO.LOW) sleep(.1) GPIO.output(22,GPIO.HIGH) sleep(.1) GPIO.output(22,GPIO.LOW) sleep(.1) GPIO.output(22,GPIO.HIGH) sleep(.1) GPIO.output(22,GPIO.LOW) sleep(.7) os.system('clear') print "Morse Code" loop_count = input("How many times would you like SOS to loop?: ") while loop_count {greater than} 0: loop_count = loop_count - 1 morsecode ()
Download
0 formatsNo download links available.