summaryrefslogtreecommitdiff
path: root/recourses/Buzzer.py
diff options
context:
space:
mode:
authorAbdellah El Morabit <nsrddyn@gmail.com>2024-11-07 17:00:19 +0100
committerAbdellah El Morabit <nsrddyn@gmail.com>2024-11-07 17:00:19 +0100
commit32ec9336088799c42d8aa7ace6648802e1b267cf (patch)
treebc6d718631a2f2a210b4cde462a5f7f97bd6b613 /recourses/Buzzer.py
parentfa7007d00c04fc73f668e2b7f339c3f60a64d055 (diff)
did alot of designing and testing out on a linux machine
Diffstat (limited to 'recourses/Buzzer.py')
-rw-r--r--recourses/Buzzer.py56
1 files changed, 0 insertions, 56 deletions
diff --git a/recourses/Buzzer.py b/recourses/Buzzer.py
deleted file mode 100644
index 8555184..0000000
--- a/recourses/Buzzer.py
+++ /dev/null
@@ -1,56 +0,0 @@
1#!/usr/bin/env python
2
3import RPi.GPIO as GPIO
4import time
5
6# Set #17 as buzzer pin
7BeepPin = 17
8
9def print_message():
10 print("========================================")
11 print ("| Beep |")
12 print ("| ------------------------------ |")
13 print ("| Buzzer connect to GPIO0 |")
14 print ("| |")
15 print ("| Make Buzzer beep |")
16 print ("| |")
17 print ("| |")
18 print ("========================================\n")
19 print 'Program is running...'
20 print 'Please press Ctrl+C to end the program...'
21 raw_input ("Press Enter to begin\n")
22
23def setup():
24 # Set the GPIO modes to BCM Numbering
25 GPIO.setmode(GPIO.BCM)
26 # Set LedPin's mode to output,
27 # and initial level to High(3.3v)
28 GPIO.setup(BeepPin, GPIO.OUT, initial=GPIO.HIGH)
29
30def main():
31 print_message()
32 while True:
33 # Buzzer on (Beep)
34 print 'Buzzer On'
35 GPIO.output(BeepPin, GPIO.LOW)
36 time.sleep(0.1)
37 # Buzzer off
38 print 'Buzzer Off'
39 GPIO.output(BeepPin, GPIO.HIGH)
40 time.sleep(0.1)
41
42def destroy():
43 # Turn off buzzer
44 GPIO.output(BeepPin, GPIO.HIGH)
45 # Release resource
46 GPIO.cleanup()
47
48# If run this script directly, do:
49if __name__ == '__main__':
50 setup()
51 try:
52 main()
53 # When 'Ctrl+C' is pressed, the child program
54 # destroy() will be executed.
55 except KeyboardInterrupt:
56 destroy() \ No newline at end of file