
Beep a PC Speaker Add Beeper to Raspberry Pi
by Lewis Loflin
Beeping the speaker on a Linux PC is simple. Open a text editor and copy the following code. Assuming one has sudo permissions with a password and in a recent Debian desktop save the file as beep.sh in /home/whoever/bin.
#!/bin/sh
# beep the speaker
# has to have sudo without password set.
sudo sh -c "echo -e '\a' > /dev/console"
Open terminal in bin set to executable:
sudo chmod + x beep.sh
Type beep.sh and speaker will beep.

Raspberry Pi
The Raspberry Pi no buzzer or speaker. I added one as shown above. This involved compiling a small program using WiringPi.
Place compile binary in /home/pi/bin. open terminal:
~ $ sudo chmod +x beep
#include <wiringPi.h> #include <stdlib.h> #include <stdio.h> #define beepPin 18 int main() { if (wiringPiSetup() == -1) exit(1); wiringPiSetupGpio(); // Use Broadcom pin numbers // 1 is OUTPUT; 0 is INPUT pinMode(beepPin, 1); digitalWrite(beepPin, 1); // on delay(300); digitalWrite(beepPin, 0); // off printf("Beep"); return 0; }
- Software and setup:
- Raspberry Pi Openbox Desktop 2019
- Setting up Openbox for Raspberry Pi
- Using FEH Wallpaper Setter Under Linux
- Add MPG123 Terminal Music Player to Raspberry Pi, Linux
- Basics of Alsamixer Audio Control for Linux
- Tutorial Xinitrc Desktop Manager Control for Linux
- Main Light Fast Linux Desktops with Openbox, JWM
- Test Reuse Surplus PC Power Supplies
- Add WBAR Launch Dock to Raspberry Pi
- Add Solid State Hard Drive to Raspberry Pi
- Beep a PC Speaker Add Beeper to Raspberry Pi
- Scrot Lite Weight Screen Shot Software for Linux
- Using Light Weight Beaver Text Editor
- Install Viewnior Image Viewer for Linux
- Zmixer ALSA Sound Control Tutorial
- Setup Raspberry Pi Using JWM Window Manager
- Live Linux Distro for Using Printer Port with Electronics
- Using the powerful Rox-Filer system in Linux
- Use FEH under Linux for a Wallpaper Setter
- How to create Symbolic links in Linux
- Exploring Digital Computer Electronics
- Hardware
- Hardware Review Connecting PC Parallel Ports
- Operation TB6600 Stepper Controller with PC Parallel Port
- Build or Buy Parallel Port Breakout Board?
- Build Serial HD44780 LCD Display Connect to Parallel Port
- Motherboards
- Presario 1999 CM1001 Gaming Computer Salvage
- Live Test 2002 VIA EPIA-800 Mini ITX Motherboard
- Salvage, Test 2012 AAEON EMB-B75A Industrial Motherboard
Web site Copyright Lewis Loflin, All rights reserved.
If using this material on another site, please provide a link back to my site.