Skip to content

Instantly share code, notes, and snippets.

View ColtonMSmith's full-sized avatar

Colton ColtonMSmith

  • Sedalia, Colorado
View GitHub Profile
@ColtonMSmith
ColtonMSmith / README.md
Last active October 6, 2024 20:45 — forked from savetheclocktower/README.md
Using a rotary encoder as a volume control for the Raspberry Pi

Using a rotary encoder as a volume control

On my RetroPie machine I wanted a hardware volume knob — the games I play use a handful of emulators, and there's no unified software interface for controlling the volume. The speakers I got for my cabinet are great, but don't have their own hardware volume knob. So with a bunch of googling and trial and error, I figured out what I need to pull this off: a rotary encoder and a daemon that listens for the signals it sends.

Rotary encoder

A rotary encoder is like the standard potentiometer (i.e., analog volume knob) we all know, except (a) you can keep turning it in either direction for as long as you want, and thus (b) it talks to the RPi differently than a potentiometer would.

I picked up this one from Adafruit, but there are plenty others available. This rotary encoder also lets you push the knob in and treats that like a button press, so I figured that would be useful for toggling mute on and off.

@ColtonMSmith
ColtonMSmith / interfaces
Created March 4, 2024 01:53
Interfaces file for HOSTAPD hotspot
#WLAN interface
auto wlan0
iface wlan0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.1
#dns-nameservers 9.9.9.9
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
#LTE modem in ECM mode (optional)
@ColtonMSmith
ColtonMSmith / dnsmasq.conf
Created March 4, 2024 01:51
Basic DNSMasq setup for hostapd
#Set the wireless interface
interface=wlan0
#Set the IP range for the clients
dhcp-range=192.168.1.2,192.168.1.250,12h
#Set the gateway IP address
dhcp-option=3,192.168.1.1
#Set DNS server address
dhcp-option=6,1.1.1.1
## BAsed on guide from : https://infosecwriteups.com/how-to-set-up-an-access-point-with-hostapd-3c18760e6f7e
@ColtonMSmith
ColtonMSmith / hostapd.conf
Created March 4, 2024 01:50
Basic HostAPD.conf 5ghz config
interface=wlan0
bridge=br0
driver=nl80211
ssid=your_ssid
hw_mode=a
ieee80211n=1
ieee80211ac=1
channel=48