Seven Segments of Pi – From Jamboree to CamJam (Part 3)

FromJamboreeToCamJam_Banner

After last week’s…

jamboreegrab2

I have returned with more ideas for Raspberry Pi add-ons…but they might have to wait until 2015! I am going to be busy this year getting “The PiTrol” and “PiDapter” ready…but I found some willing pupils who I met at the Jamboree keen to test-drive these kits!

Now back to 2012! I had just started going into schools with my shiny new Raspberry Pi only to get the response…

but_what_does_it_do

“Yes! …but what does it do!?”

This spurred me into action. I had to make it “do” something to gain their interest! Thanks to my colleagues at work I had decided to try and hook the Raspberry Pi up to a Seven Segment Display using the Raspberry Pi’s GPIO Pins.

The GPIO Pins are a feature of the Raspberry Pi which sets it apart from a “normal” PC. Connecting to the GPIO Pins allows you to directly control other electronics, something that was possible on the BBC Micro

BBC_Micro

…in the 1980’s but became difficult to do on a “normal” PC in the 1990’s! (And if attempted, would be frowned upon by most parents!)

Part 3 “Building the Segments of Pi”

Rummaging through my boxes of old bits of electronics dating back to my time at Sheffield University I found a Seven Segment Display board I had built on Vero Board. I salvaged the 12mm Seven Segment Display and plugged it into a Breadboard. After downloading the Raspberry Pi Schematics I found the “P1 Connector” had 7 GPIO, labelled GPIO_GEN0 to 6. Just the right number for my display!

In the Dark Ages of 2012 no one seemed to have invented a convenient way to connect the Raspberry Pi’s “P1” Connector to a Breadboard (The Adafruit Pi Cobbler adapter…

AdafruitPiCobbler

…came along some months later!) So I rigged up a “Heath-Robinson” Ribbon Cable to connect my Raspberry Pi to the Breadboard and I had…

SevenSegmentsMarkI

Seven Segments of Pi Mark I

I now just had the small matter of how to drive the GPIO from software! A few Google Searches later it was clear “Python” was the programming language of choice for the Raspberry Pi when using the “Debian” Operating System. I then found Simon Monk’s instructions…

Monk_Makes

…showing how to control the GPIO from “Python”. Following his instructions I downloaded the RPi.GPIO Python Library (this is now pre-installed in the Raspbian Operating System) and found I needed to be logged-in as “Super User” (sometimes referred to “Supervisor” “Administrator” or “sudo”)

I tried toggling GPIO_GEN0 as GPIO.output(0) in my “Python” software.
Nothing happened!

Looking at the Schematics I found GPIO_GEN0 was actually GPIO17 from the Broadcom chip. I tried toggling GPIO_GEN0 as GPIO.output(17) in my “Python” software.
Still nothing happened!

A few more Google Searches later and I found that the “Python” Library references the GPIO by their “P1 Connector” Pin Number (not the schematic signal name nor the Broadcom GPIO number) so GPIO_GEN0 is GPIO.output(11)!
It now worked! I had control of my Seven Segment Display!

There was one slight problem! I needed to set the GPIO to “False” to turn the Segments “on” and “True” to turn them “off”! That would be sure to cause confusion in the Classroom! So it was time for…

SevenSegmentsMarkII

Seven Segments of Pi Mark II

A larger “common anode” Seven Segment Display driven by an Inverting Buffer now meant “True” turned it “on” and “False” turned it “off”! Two IDC Connectors on the Ribbon Cable allowed me to connect to the Breadboard in a more elegant way, and with the addition of a single PushButton as a GPIO.input I had something I could take back into schools.

I was still limited by having just one Raspberry Pi, but this time after my presentation I gave the pupils the chance to get their hands on the “Pi”!
I had written a Python Program that displayed the numbers 1,2,3 in sequence on the Seven Segment display when the PushButton was pressed…

SevenSegmentsOneTwoThree_Thumbnail

Download the code

Three pupils stayed behind to take a closer look. I showed them the Python software and said “See if you can make it count to 4!”

They had never written any software before but they were off!
They quickly defined a new function called “four” and realised that to display the number “4” on a Seven Segment Display segments b,c,f & g must be “True”. The rest must be “False”…

Seven_Segments_of_Pi_Assy_LED1_with_Letters

But it still didn’t count to “4”! They had not called the function “four”!

A few syntax errors later and there was a “Yessss!” from the other side of the classroom. They had made it count to 4!!!

Seven_Segments_of_Pi_Assy_LED_Displaying_4

…and now they wanted to make it count to 5! …but it was 5.30pm and the teacher needed to lock up the Classroom! “Just give us a few more minutes so we can make it count to 5” they said. That was the moment I realised this simple idea of hooking the Raspberry Pi up to a Seven Segment Display “worked”! It was simple enough for someone new to programming to understand, but challenging enough to be satisfying when it “worked”! Now all I needed was a more comprehensive set of Software Challenges plus a few more Raspberry Pi’s and I could run Raspberry Pi Workshops in Schools!

Next week I will look at some of the technical barriers to using the Raspberry Pi in the classroom in a Blog entitled

”Yes! …but all our monitors are VGA!”

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

 

Budget robot kit for the #RaspberryPi just launched

Ryan Walmsley, creator of Rastrack and co-editor of Pi Weekly (and constant CamJam attendee!), has had a great success with his RTK motor controller board and has now branched out into a full beginners robot kit. The kit includes almost everything you need to get a robot up-and-running:

  • A RTK motor controller board kit
  • A chassis
  • A wi-fi adapter
  • A battery box for driving the motors
  • 2 motors and wheels
  • Wires to connect it up and screws to assemble it
  • Lots of documentation and code

He is running the kits as an Indiegogo campaign and so you have some options:

  • £33 – the kit with a motor controller board you’ll have to solder yourself
  • £35 – the kit with a soldered motor controller board
  • There’s also a 5-robot set available for schools at £148 (which is quite a saving).

For the first ten he sells, there’s a £3 discount on the basic kit so you could pick one up for £30.

The only things you will need to get yourself are: a Raspberry Pi, batteries for the motor pack and a portable power source for the Pi. Ryan’s decided not to include these as shipping of batteries carries with it a load of regulations and possible extra charges.

You will be hard-pushed to find a better kit at a better price. The quality is good and has been fully tested by Ryan.

Go and get one now if you want to get into robotics!

I’m not affiliated to Ryan or his business, I just think this is a great kit at a great price and I like to support new business where I can.

Wolfson audio card now available for the #RaspberryPi

As previewed on this site in November, the Wolfson Audio card for the Raspberry Pi is now available from Element 14. It has the following features:

  • 3.5 mm jack (4-pole) for a headset/boom mic combination for gaming or VoIP applications
  • 3.5 mm jack for microphone input
  • On-board MEMS microphone
  • 3.5 mm jack stereo line input for connection to devices such as digital audio players (iPod etc.) or mobile phones
  • 3.5 mm jack stereo line output for connection to devices such as external stereo amplifiers or powered speakers
  • S/PDIF input and output
  • On-board class D power amplifier for external speakers, with connection to external power source if needed.
  • Small pin header for extra functions if they are low cost, already on-chip, and don’t require any further components
  • Raspberry Pi form factor

It’s currently available for £24, which isn’t at all bad for this quality of kit and is only compatible with Revision 2 Pis – the ones with the extra P5 pads. You don’t need to solder a header onto the pads as the card uses an ‘innovative sprung’ mechanism to connect to the pads. (I’m not sure what that looks like in practice, but it sounds like a very cool, and sensible, way of getting around the P5 header dilemma).

#RaspberryPi for Dummies – book review

9781118554210.pdfRaspberry Pi for Dummies was sent to me by Wiley for review. So here goes!

Written by Sean McManus and Mike ‘Grumpy Mike’ Cook, Raspberry Pi for Dummies is a comprehensive look at setting the Pi up, administering it, using it as an office machine, using it for programming and using it for hardware hacking.

It’s written in an easy-going (occasionally anarchic) style which fits in with all the other ‘Dummies’ guides that are out there. This book has personality and it’s easy to like the style.

To start with, the Pi is introduced and the hardware discussed. I particularly liked the section on it’s limitations as this is essential information to grasp if you are to use your Pi to it’s limits. Following that, there is a description of downloading and flashing an operating system to your SD card. This is now out-of-date as the best way of getting the OS onto your SD card is now to use NOOBS, but the information is still accurate if you want to do it manually. After that, the writers take us through the various peripherals you need to plug in to take your Pi from being an attractive circuit board to being a fully usable computer. I was disappointed that there wasn’t mention of how to connect to a VGA monitor (which is a not-uncommon problem) using an adapter. They also do not cover connecting to a wi-fi network, which is a shame, as some homes do not have their router in a suitable location.

The next part covers using Linux both via the desktop and via the command line. The Linux shell section is particularly good here and covers all the commands you’re like to want to use in day-to-day operation. There’s lots of info about file management here, which is good to see.

The next part is about using the Pi for “work and play”. This section covers using a couple of software packages: LibreOffice for basic office work and GIMP for image manipulation. This is useful as these two activities are the most common when using a computer, so it’s worthwhile having them there, if only so people can understand the analogue between something like Microsoft Office and the package you’d use on the Pi. After that, the book takes you through creating a website with the Pi. This is the first time you’re asked to do something creative and seems slightly out-of-keeping with the purpose of the Pi. However, it’s pretty comprehensive and does delve into the HTML to help you understand it. The book then continues into installing and using RaspBMC to play audio and video on the Pi. Again, this feels slightly odd. I would’ve preferred to have seen how to play video and audio through the normal desktop interface that you’d already been introduced to.

Part 4 covers programming in two flavours: Scratch and Python. Programming concepts are introduced and there are fully worked examples for both languages. I particularly like the section in Scratch which deals with fixing a ‘bug’ – a great skill for every programmer to have. The Python section is good and again introduces programming concepts before moving onto the example scripts. Pygame is also covered here and there’s a great Breakout example game to type in and follow.

Part 5 is titled “Exploring Electronics with the Raspberry Pi”. There is some great fundamental electronics information here and you are introduced to concepts such as resistance, current etc. The GPIO pins are introduced and described so that the beginner can understand what those ‘sticky up bits’ are. There is also a very good section on soldering here – very good for the beginner, though more pictures might have helped. However, I would have preferred much more breadboarding electronics here – I think the authors have missed a trick by delving so quickly into soldering. While it’s true that most electronics projects result in needing to solder, it is also true that most projects start out on breadboards and they could have spent much more time on that medium before moving onto more permanent circuits. This part of the book then moves onto creating a fully-fledged project. It seemed a bit quick to me and again, the lack of prototyping shows here. I would like to have seen something like the Pi Cobbler be used with a breadboard showing how most people start out. Whereas the beginning of the book could be understood by young teenagers, I think by this point in the book it would take an adult to get to grips with what they’re talking about. Then next bit deals with using the GPIO pins more extensively and then moves onto capturing analog inputs. This is quite advanced stuff now and I wonder if it isn’t perhaps too complex for a ‘Dummies’ book. I was particularly surprised to see a “surface mount” component in use. Remembering that the reader has probably only started to solder, surface mounting would be way beyond their capabilities.

The final part of the book is “The Part of Tens” which is a standard fixture with Dummies books. In this Dummies book, the writers cover 10 “great software packages” and 10 “inspiring projects”. The inspiring projects bit is particularly good as it leads the reader to blogs where they might find additional projects as well as the 10 featured.

There are two appendices. The first is a troubleshooting guide (in which ‘change the power supply’ is surprisingly near the end of the basic steps list) and the second is a list of the GPIO pins and what functions they perform. As expected, there is also a comprehensive index.

In conclusion

There are a few flaws with the book – my main issue being with how quickly it gets into complex circuitry and soldering concepts. That’s not to say the information is wrong or inappropriate – but the speed of the book in this part accelerates too quickly in my opinion. I wonder if this book might be better off in the hands of parents with Pis rather than children.

Having said that, the other parts of the book more than make up for any ‘scare factor’ that the complex concepts might provoke. The basic maintenance, productivity and programming sections are excellent.

So, a mixed reception for this book, but not an overtly negative one. I must score it a solid 7/10.

Focus on Education @ the Cambridge Raspberry Jam – 10th May

Come along and listen to a variety of talks and presentations centring on the new Computing curriculum and how it affects schools at both Primary and Secondary level. We will explore the challenges of the new curriculum, what resources there are available to teachers and other educators and see how the Raspberry Pi can help to deliver results in the classroom.

You will also be able to to see young people, and older people, use the Pi in practical workshops.

Focus on Education is being run as part of the Cambridge Raspberry Jam and will take place on Saturday 10th May between 12pm and 6pm at The Institute of Astronomy, Madingley Road, Cambridge. Tickets are £3.50 each.

To register, please use our EventBrite page. If you have any questions, please don’t hesitate to ask!