💾 Archived View for capsule.adrianhesketh.com › 2020 › 03 › 15 › real-terminal-bell captured on 2023-07-10 at 13:38:47. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

capsule.adrianhesketh.com

home

Real terminal bell

I decided that I didn't like the sound of the terminal bell on my computer. Wouldn't it be nicer if it was an actual bell?

So, I got a Raspberry Pi, a servo motor and some lego and built a real terminal one.

bell_house.jpg

I didn't want to spend long on it, so I used some example Python code from [0] and added a Web server so that I could trigger the bell remotely.

[0]

from flask import Flask
import RPi.GPIO as GPIO
import time

# Create Flask app.
app = Flask(__name__)

# Start GPIO up.
servoPIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(servoPIN, GPIO.OUT)
p = GPIO.PWM(servoPIN, 50) # GPIO 17 for PWM with 50Hz
p.start(2.5) # Initialization

@app.route("/ding")
def hello():
    p.ChangeDutyCycle(7.5)
    time.sleep(0.3)
    p.ChangeDutyCycle(6.5)
    time.sleep(0.6)
    return "dong"


if __name__ == '__main__':
    try:
        app.run(host = '0.0.0.0',port=5005)
    except KeyboardInterrupt:
        p.stop()
        GPIO.cleanup()

With that in place, I could get the bell to ring using curl.

curl 192.168.0.52:5005/ding

My son and I then set to work building a lego case.

I use [1] to manage my terminal, so it was a simple case of using the built-in hook feature [2] to run the command when the bell rings, and to disable the bell sound on my mac:

[1]

[2]

set-hook -g alert-bell 'run-shell "curl 192.168.0.52:5005/ding"'

<img src="/2020/03/people.jpg"/>

Ah... much nicer.

You can see a video and hear it in action at [3]

[3]

More

Next

Single table pattern DynamoDB with Go - Part 1

Previous

Mocking AWS SDK calls in Go

Home

home