In addition to the starting switch, we applied an active buzzer that beeps three times when the Raspberry Pi turned on. This is important to know when the Raspi has fully booted because you can't see when everything has loaded, since there is no display.
The buzzer is connected to the GPIO pin 19 and to GND. To make life easier for us we chose to use an active buzzer that doesn't need to be switched on and off to generate a sound, it simply needs to be connected to power for the time you would like to hear the buzz.
Again, this was tested on a different Raspberry on a breadboard before we went to install it on the "ready prototype". We only have this one mobile prototype and we have promised to send it to a patient in need asap - so we need to make sure everything is fine.
Here we need to add some code - first, we import some libraries:
import RPi.GPIO as GPIO #for the pins
import time #for delaying
Next we define the GPIO pin for the buzzer:
buzzerpin = 19 # attach buzzer between pin19 and GND; check polarity!
GPIO.setmode(GPIO.BCM) # use BCM numbering scheme as before
GPIO.setup(buzzerpin, GPIO.OUT)
time.sleep(0.5) # give it a short rest
As soon as everything is set up (camera etc.) we want the buzzer to make a short beeping sequence to notify the user that a connection to the streaming NIR video is now possible. We opted for a short 3x beeping sound:
for i in range(1,4): # runs 3 times
GPIO.output(buzzerpin, True) # switch to high (=switch active buzzer on)
time.sleep(0.2) # time between beeps
GPIO.output(buzzerpin, False) # switch to low (=switch active buzzer off)
time.sleep(0.2)
That was all - it worked astonishing well ;-)
Now we have a little snippet we can add to the main code later... just before the main loop starts. Next task will be the power-off routine...
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.