User Manual

61
For C language users:
Step 2: Open the code file
cd /home/pi/SunFounder_Super_Kit_V3.0_for_Raspberry_Pi/C
Step 3: Compile the Code
make 06_beep
Step 4: Run the executable file above.
sudo ./06_beep
Code Explanation
digitalWrite(BeepPin, LOW); // We use an active buzzer in this experiment, so it will
make sound automatically when connecting to the direct current. This sketch is to set
the I/O port as low level (0V), thus to manage the transistor and make the buzzer beep.
digitalWrite(BeepPin, HIGH); // To set the I/O port as high level(5V), thus the
transistor is not energized and the buzzer doesn’t beep.
For Python users:
Step 2: Open the code file
cd /home/pi/SunFounder_Super_Kit_V3.0_for_Raspberry_Pi/Python
Step 3: Run
sudo python 06_beep.py
Code Explanation
GPIO.output(BeepPin, GPIO.LOW)# Set the buzzer pin as low level.
time.sleep(0.1)# Wait for 0.1 second. Change the switching frequency by changing this
parameter. Note: Not the sound frequency. Active Buzzer cannot change sound frequency.
GPIO.output(BeepPin, GPIO.HIGH) # close the buzzer
SunFounder