Third party cookies may be stored when visiting this site. Please see the cookie information.

Home Family Days Out Raspberry Pi & Electronics Blog


Welcome to the website of Stewart Watkiss.

I’m a Data Centre Manager, a STEM Ambassador, an author, a first aider, an assistant Cub Scout Leader, a graduate student and most importantly a husband and father of two children.

You can find out a bit more about Stewart Watkiss.
Any comments or suggestions contact me using my email form.

Latest Blog Entry

JLL Piano - Raspberry Pi Music Clip player

This project is called the JLL piano. This is a school project that my daughter created for her music homework. She needed to create a project that related to Jerry Lee Lewis and she created a mini piano that plays a short clip for a different song depending upon the key that is pressed.

Raspberry Pi Piano Hat

It uses a Raspberry Pi with a Pimoroni Piano Hat.

You first need to setup the Piano Hat using the Pimoroni Piano Hat install instructions. Then create the following in a text editor.
The program will work in Python 2 or Python 3.

You can of course change the music clips to be any music you prefer.

import pianohat
import time
from pygame import mixer

# Change key numbering (black keys = -1)
keys = [0,-1,1,-1,2,3,-1,4,-1,5,-1,6,7]

sound_files = [

def inc_volume(ch,evt):
if evt:

def dec_volume(ch,evt):
if evt:

# Change volume by amount specified 0 to 10 (+1, -1 etc.)
def change_volume (change):
#print ("Change volume "+str(change))
if change == 0 : return
# volume is 0 to 1 so divide by 10
delta = change / 10
new_volume = sounds[0].get_volume() + delta
if new_volume > 1:
new_volume = 1
if new_volume < 0: new_volume = 0 for this_sound in sounds: this_sound.set_volume(new_volume) def handle_note(channel, pressed): if pressed: channel = keys[channel] if (channel < 0): return mixer.stop() sounds[channel].play(loops=0) mixer.init(22050, -16, 2, 512) mixer.set_num_channels(13) sounds = [mixer.Sound(sound_file) for sound_file in sound_files] pianohat.on_note(handle_note) pianohat.on_octave_up(inc_volume) pianohat.on_octave_down(dec_volume) while True: time.sleep(0.001)

View more Blog Entries

UK days out, children and holiday information is also available on the Days Out Diary web site
Linux, LPI and the Quiz / Test Program posts are also available on the Penguin Tutor website
First Aid Information, first aid games and first aid practice test / quiz entries are also available on the First Aid Quiz Web site