Seven Segments of #RaspberryPi in the Classroom (part 9 – Final part!)

This is the final part of the Seven Segments of Pi series we’ve been running over the past few weeks. A massive Thank You! to Nevil Hunt for taking the time to share his adventures!

FromJamboreeToCamJam_Banner

Part 9 – Have the Audacity to make your own sound effects! … D’oh! There’s no sound!

Last week I talked about how I came up with a game to play on the Seven Segments of Pi called “Figure Eight My Pi” and enjoyed seeing how the pupils were inspired to come up with their own ideas. In this week’s final Blog in the series I will describe how the pupils embraced the challenge of writing their first computer game! I will also return to the thorny issue of sound from the Raspberry Pi when using a VGA Adapter! This Blog is entitled…

”Have the Audacity to make your own sound effects!

…D’oh! There’s no sound!”

When running the…

PiStopWatch

…Workshop I introduced Sound Effects which brought the Seven Segments of Pi ‘alive’! Sound Effects make such a difference and would be needed when the pupils wrote their own version of game “Figure Eight My Pi”! I got a sound effect file “doh.wav” with Homer Simpson saying…

HomerSimpson_Doh

…and gave the pupils a Python program, “Seven_Segments_Sound.py”, demonstrating how to generate this sound effect from Python. I was sure it would raise a chuckle when the pupils heard it!

Everything worked fine at home. I had Homer Simpson coming out of my PC Speakers plugged into the Headphones Jack of my Raspberry Pi!

RaspberryPi_HeadphonesJack

I went into the first school.

They ran “Seven_Segments_Sound.py

“Now press the red PushButton” I instructed expecting a cacophony of Homer Simpsons…but instead there was silence!

  • Were all the leads plugged in? Yes they were!
  • Were all the speakers turned on?  Yes they were!
  • I was stumped! It had worked fine at home!

I returned home, plugged everything together and ran the sameSeven_Segments_Sound.py” program on the same Raspberry Pi connected to the same speakers. Homer Simpson was heard loud and clear!

I went into the second school, confident that I now had the sound working, but once again Homer Simpson stubbornly refused to co-operate!

What was going on? The only difference between my setup at home and the setup in the Classroom was the monitor. How could the monitor have anything to do with the sound?

I discovered that the Raspberry Pi has 3 audio modes…

  • 2 = Digital where audio is always sent out of the HDMI port to an HDMI television
  • 1 = Analog where audio is always sent out of the 3.5mm Jack to Headphones or PC Speakers
  • 0 = Auto where the Raspberry Pi detects the type of monitor connected and sends sound to the HDMI port if it thinks an HDMI TV is connected, otherwise it sends audio to the 3.5mm Jack.

…and “Auto” is the default mode.

At home I used a DVI monitor, which the Raspberry Pi correctly established was not an HDMI TV hence sent audio to my PC Speakers. In school, since the schools only had VGA Monitors, I used HDMI-to-VGA Adapters. These adapters were confusing the Raspberry Pi causing it to send audio to the HDMI port!

I found the Linux Command…

   sudo amixer cset numid=3 1

…would force the sound out of the 3.5mm Headphones Jack.

That would be fine for the Workshop but when the pupils returned home with their SD Card and plugged into their Raspberry Pi attached to their HDMI TV they would get no sound! Auto Audio Mode needed to work with HDMI-toVGA Adapters and to do so the HDMI-toVGA Adapters must correctly report back to the Raspberry Pi that it is not an HDMI TV!

By now I had ten HDMI-to-VGA Adapters, all bought from Amazon and all supposedly made by Neewer. I tried them out and found 4 worked fine in Auto Audio Mode, correctly sending audio to the PC Speakers. 6 didn’t!

I have now checked several different HDMI-to-VGA Adapters and most don’t handle Auto Audio Mode correctly! I can’t recommend Neewer since there seems to be no way of knowing which version you will receive! The only HDMI-to-VGA Adapter I’ve tested which handles Auto Audio Mode correctly (as well as correctly converting the video) that I can provisionally recommend is the Patuoxum sold by Patox, available via Amazon.

Back to the Classroom!

I now had over 20 pupils from 3 schools, aged from 10 to 15, most of whom now had a Raspberry Pi at home, writing their version of the game “Figure Eight My Pi!”

It was quite a challenge. Some had parents who were software engineers to help at home, many did not! But they were all making progress!

Just like the PiDice and the PiStopWatch they were not starting with a blank sheet of paper. I provided them with the starting software in which a single segment (The PiSeg!) went round the Seven Segment Display in a figure zero…

Seven_Segments_of_Pi_Figure_Zero

Their first task was to make the single segment go round in a figure eight…

Seven_Segments_of_Pi_Figure_Eight

…then make it randomly decide whether to go in a figure zero or a figure eight.

…then add Sound Effects

…then detect if the PushButton is pressed when the centre segment is illuminated.

…then speed up a little each lap.

…then keep a score.

They had now written their first computer game…

Figure_Eight_My_Pi_without_Graphics

Some progressed faster than others. But that was fine! The pupils who by now had a working game became my Classroom “Software Support Engineers” and I employed them to help resolve the bugs in the software of their fellow pupils. This worked really well! Pupils now had help other than from me! And my “Software Support Engineers” had an opportunity to demonstrate to their fellow pupils, their new-found software skills!

I still wanted to stretch the most able! So I gave them the challenge of making their own sound effects to use in their game by using the free audio capture and editing software…

Audacity

Finally the end of term arrived. I was having one last workshop before they demonstrated what they’d achieved to their fellow pupils, teachers and parents. It was nearly lunchtime and I was helping a pupil solve a tricky bug and I could hear the other pupils in the room…but when I looked round the room was deserted! They had left their games playing and what I was actually hearing was their voices, recorded and edited using Audacity, being played as sound effects in their games!

So on the last day of term they demonstrated what they had achieved. I had nothing more to do. I had no more software bugs to solve or bits of electronics to fix. I could just enjoy seeing the pride the pupils had explaining how their software worked to their fellow pupils, teachers and parents! It was without doubt one of the most satisfying moments in my life as a STEM Ambassador and gave me the spur to making the “Seven Segments of Pi” available as a kit so other pupils have the chance to take on the “Seven Segments of Pi” Challenge! And maybe in years to come the Raspberry Pi will be seen as having been the catalyst to creating a new generation of software and electronics engineers!

CholseyRaspberry PiWorkshop

Thank you for following this series of Blogs. If you are interested in learning more about the Seven Segments of Pi visit my Web Site www.SevenSegmentsOfPi.com or watch the “Seven Segments of Pi” YouTube Video. You can also watch Carrie Anne Philbin playing “Figure Eight My Pi” at the CamJam, courtesy of Alex at RasPi TV.

NevilHuntPhoto_QuarterSize

Nevil Hunt
Innovations in Education

Using Plotly to create a graph of dissolved oxygen with the #RaspberryPi

Here’s an interesting one for those of you (like me) who like sensors. Someone’s taken an Atlas Scientific dissolved oxygen sensor and breakout board and connected it up to a Raspberry Pi. The Pi then runs a piece of Python script and uses Atlas’ library to read the data and feeds it into Plotly to plot the graph. Read more here. It’s not a cheap project (the Atlas components are close to $200) but is interesting to see how the Plotly interface is done.

Dawn Robotics publishes new #RaspberryPi robot code

Internet retailer Dawn Robotics has released new versions of some of the software for their robot bundle. The update includes a new camera streaming script and a shutdown button for the web interface. It’s well worth looking at their page and their code for ideas for your own robot, even if you’re not using their kit. It’s always great to see retailers releasing code to the community and we should commend them for their efforts! Read more here