Skip to content

Instantly share code, notes, and snippets.

View DavesCodeMusings's full-sized avatar

Dave Horton DavesCodeMusings

  • Planet Earth
View GitHub Profile
@DavesCodeMusings
DavesCodeMusings / interrupt_pwm.ino
Last active April 7, 2026 20:47
Interrupt-driven PWM for Arduino
/*
Interrupt driven pulse width modulation for ATmega328 (a.k.a. Arduino Uno R3.)
Vary the brightness of an LED on a non-PWM capable pin.
*/
#define LED_PIN 13 // The builtin LED on Arduino Uno.
#define BRIGHTNESS 6502 // Must be less than 65536. Values of 40 or less may give unpredictable results.
// Turn the LED on when the timer wraps around to zero.
ISR(TIMER1_OVF_vect) {
@DavesCodeMusings
DavesCodeMusings / sleep_wake_echo.ino
Last active April 2, 2026 04:13
ATMega328 (Arduino Uno) sleep mode, external interrupt wake, serial echo.
/*
ATMega328 (Arduino Uno) sleep mode, external interrupt wake, serial echo.
This sketch is a proof of concept for sleep with very low power draw.
The sketch echoes whatever is sent to the serial input back to the
serial output. This is only interresting because it gives solid proof
the microcontroller is awake. (If you type and it echoes, it's awake.)
Pins 2 and 3 are configured as interrupts to put the microcontroller
@DavesCodeMusings
DavesCodeMusings / link-title-dynamic-display.html
Created March 17, 2026 15:15
CSS attr() function and the ::after pseudo element used to dynamically display link title after link text
@DavesCodeMusings
DavesCodeMusings / compose.yml
Created January 16, 2026 13:42
Kanboard Docker compose with OpenLDAP authentication example (change environment to match your needs)
name: kanboard
services:
app:
image: kanboard/kanboard:latest
container_name: kanboard
restart: unless-stopped
ports:
- "8080:80"
- "8443:443"
volumes:
@DavesCodeMusings
DavesCodeMusings / gpsdump.sh
Last active January 10, 2026 16:06
Display data from serial attached GPS device for testing.
#! /bin/sh
# Display data from serial attached GPS device for testing.
PORT=/dev/ttyACM0
SPEED=9600
echo "Reading from $PORT at $SPEED bps."
stty -F $PORT $SPEED
#! /bin/sh
# When you're not using systemd on your Raspberry Pi, you
# can still enjoy GPIO push-button shutdown.
# Run this as:
# gpio_pwr_btn.sh &
# It will sit in the background and wait for GPIO to go low.
# When it does, it will issue the shutdown command.
GPIO=GPIO26
; Prevent recreation of System Volume Information by blocking it with an empty file of the same name.
; Does System Volume Information store presonally identifiable information? I don't know.
; Do I want Windoze automagically creating stuff on my Raspberry Pi microSD? No, I don't.
; Must be run with admin privs
dir /a
cd REMOVEABLE_DRIVE_LETTER (e.g. D:)
rmdir /s "System Volume Information" & copy NUL "System Volume Information"
attrib +h "System Volume Information"
@DavesCodeMusings
DavesCodeMusings / Armbian Ubuntu on Orange Pi Zero 3.md
Last active December 14, 2025 13:06
Installing and tweaking Ambian Ubuntu for the Orange Pi Zero 3 for fun and profit!

Ubuntu Server on Orange Pi Zero 3

Even with the current tariff nonsnese, the Orange Pi Zero 3 is a cheap and fairly capable ARM single board computer (SBC). If you've mastered the Raspberry Pi and you want to branch out, Armbian Ubuntu on the Zero 3 is a good place to start.

Download and flash the Armbian Ubuntu binary image

  1. Visit the Armbian Orange Pi Zero 3 page
  2. Scroll down to Server images
  3. Download Ubuntu 24.04 (Noble), the current version at time of writing.
  4. Use Raspberry Pi Imager, Balena Etcher, or whatever to flash the binary image to microSD.

Attach a console to the Orange Pi

@DavesCodeMusings
DavesCodeMusings / tasmota-esp32c3-install.cmd
Last active December 13, 2025 16:20
Tasmota flash firmware on ESP32-C3 with esptool on Windoze 11
; This assumes Python and esptool module are installed and working.
; Download the factory image for a fresh install
curl.exe --output tasmota32c3.factory.bin --url http://ota.tasmota.com/tasmota32/release/tasmota32c3.factory.bin
; Erase before flashing
py -m esptool --port=COM3 erase_flash
; Flash the image to the first detected COM port at offset 0
py -m esptool write_flash 0x0 .\tasmota32c3.factory.bin
@DavesCodeMusings
DavesCodeMusings / README.txt
Created July 24, 2025 12:59
syslog-ng in Docker for logging network hosts
Creates a syslog server that can be used to centrally collect logs from various network devices.
You'll need a Docker compose project directory structure that looks like this:
-rw-r--r-- 1 root root 351 Jul 24 12:00 compose.yml
drwxr-xr-x 3 1000 1000 4096 Jul 24 12:00 config/
drwxr-xr-x 2 1000 1000 4096 Jul 24 12:00 logs/
The syslog-ng.conf goes in the config/ directory. Logs will be found in the logs/ directory.
Logs are rotated daily.