If I only had a heart

I recently coordinated the ‘tech’ for the school production of “The Wizard of Oz” and was really keen to see if there was a use for the Raspberry Pi in either the special effects or as a prop.

woz

I decided to use the Pimoroni Unicorn Hat with a raspberry pi model A+ to provide a glowing animated heart for the Tin Man.

IMG_0167
IMG_0162

The code was relatively simple and I used a simple list to assign the x,y and colour data for each pixel to be used.

myList1=[3,2,3,4,1,2,3,4,5,0,1,2,3,4,5,6,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,5,6,7,1,2,6]
myList2=[0,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7]
myList3=[1,1,2,1,1,2,2,2,1,1,2,2,2,2,2,1,1,3,3,2,2,2,2,1,1,3,3,2,1,2,2,1,1,2,2,1,1,2,1,1,1,1]

To give the effect of the heart beating and pulsating I gradually changed the brightness of the pixels from about 30 – 80%. It was important not to go too bright as I could have blinded the audience or other cast members!

while True:
for bright in range (30,80):
UH.brightness(bright*0.01)
heart()

This gave a very passable beating effect which looked stunning on the stage. The Pi was powered with a portable battery pack and to make backstage life easier the code was activated from boot using crontab with.

@reboot sudo python /home/pi/Pimoroni/heart.py &

Wizard of Oz heart

Leave a Reply

Your email address will not be published. Required fields are marked *