Tag Archives: Uncategorized

Raspberry Pi Zero: the $5 computer

via Raspberry Pi

Of all the things we do at Raspberry Pi, driving down the cost of computer hardware remains one of the most important. Even in the developed world, a programmable computer is a luxury item for a lot of people, and every extra dollar that we ask someone to spend decreases the chance that they’ll choose to get involved.

Private Video on Vimeo

Join the web’s most supportive community of creators and get high-quality tools for hosting, sharing, and streaming videos in gorgeous HD with no ads.

The original Raspberry Pi Model B and its successors put a programmable computer within reach of anyone with $20-35 to spend. Since 2012, millions of people have used a Raspberry Pi to get their first experience of programming, but we still meet people for whom cost remains a barrier to entry. At the start of this year, we began work on an even cheaper Raspberry Pi to help these people take the plunge.

Four fathers!?!??

Four fathers!?!??

Today, I’m pleased to be able to announce the immediate availability of Raspberry Pi Zero, made in Wales and priced at just $5. Zero is a full-fledged member of the Raspberry Pi family, featuring:

  • A Broadcom BCM2835 application processor
    • 1GHz ARM11 core (40% faster than Raspberry Pi 1)
  • 512MB of LPDDR2 SDRAM
  • A micro-SD card slot
  • A mini-HDMI socket for 1080p60 video output
  • Micro-USB sockets for data and power
  • An unpopulated 40-pin GPIO header
    • Identical pinout to Model A+/B+/2B
  • An unpopulated composite video header
  • Our smallest ever form factor, at 65mm x 30mm x 5mm

Raspberry Pi Zero runs Raspbian and all your favourite applications, including Scratch, Minecraft and Sonic Pi. It is available today in the UK from our friends at element14, The Pi Hut and Pimoroni, and in the US from Adafruit and in-store at your local branch of Micro Center. We’ve built several tens of thousands of units so far, and are building more, but we expect demand to outstrip supply for the next little while.

One more thing: because the only thing better than a $5 computer is a free computer, we are giving away a free Raspberry Pi Zero on the front of each copy of the December issue of The MagPi, which arrives in UK stores today. Russell, Rob and the team have been killing themselves putting this together, and we’re very pleased with how it’s turned out. The issue is jam-packed with everything you need to know about Zero, including a heap of project ideas, and an interview with Mike Stimson, who designed the board.

MagPi #40 in all its glory

MagPi #40 in all its glory

If you’re looking for cables to go with your free Zero, head over to the newly revamped Swag Store, where we’re offering a bundle comprising a mini-HDMI and a micro-USB adapter for just £4, or alternatively subscribe and we’ll send you them for free.


Happy hacking!​

The post Raspberry Pi Zero: the $5 computer appeared first on Raspberry Pi.

Alex’s Nixie Clock

via Raspberry Pi

Liz: Alex is ten years old. He lives in Texas. He shared his most recent school project with us. It’s a great project and a fantastically clear tutorial: we thought you ought to see it too.

My Mom wanted a Nixie Clock, and I needed to do a project for school. I had a Raspberry Pi I wasn’t using, so I built a Nixie Clock. It took me about 2 months.

Raspberry Pi Nixie Clock

This is my Raspberry Pi Nixie Clock. It took me about 2 months to build because I had to learn so much. Full details can be found on my blog: http://alex.atomicburn.com

My Dad ordered some Nixie tubes and chips from Russia, and bought a 170V power supply to power the Nixie tubes. The first thing to do was to test them:


To start with I installed a tube, chip and power supply onto a breadboard. The chip has 4 input lines (A, B, C, and D) that are used to tell it which number to light up. For example in binary 7 is 0111, so you need to set input A to high, B to high, C to high and D to low (A=1, B=2, C=4 and D=8) to light up the number 7. I tested the first one by using a jumper cable to connect the 4 inputs to either 0V (low) or 5V (high).

Once I knew the first tube and chip worked, I wrote a program on the Rasberry Pi to test them. I used 4 GPIO pins, wired to pins A,B, C and D on the chip. My program would loop through the numbers 0 to 9, and turn on/off the pins by converting to binary using logical AND’s.

For example – for the number 7:

  • 7 AND 1 = 1, so pin A would be set high.
  • 7 AND 2 = 2, so pin B would be set high.
  • 7 AND 4 = 4, so pin C would be set high.
  • 7 AND 8 = 0, so pin D would be set low.

Once I had the program working, it was easy to test all the chips and Nixie Tubes. Everything worked, except one tube – the 3 and the 9 would light up at the same time. So I used this for the first digit for the hours, since that only ever needs to show 1.

The Program:

When the Raspberry Pi starts up, it automatically starts my clock program.

I wrote the clock program in C using the geany editor.

When the program starts, first it sets all the digital pins to OUTPUT and LOW to make sure everything is off.

Then I turn on pin 0, which turns on the high voltage power supply using a transistor.

Then I test the clock, which makes the hours show 1 to 12, and minutes 0-59.

Then I start the loop. Once every second I do the following:

  • Ask the computer the time (if it is connected to the internet, it will always show the right time).
  • The hours come back as a number between 1 and 23, so if the hour is bigger than 12, I subtract 12 from it.
  • Then I break out the hour into 2 digits, and the minutes into 2 digits. The first digit is the quotient of the hour divided by 10. The second digit it the remainder of the hour divided by 10. Then I do the same for the minutes.
  • For each number, I have to convert it into binary (for example 7 is 0111 in binary). Each number has up to 4 wires, each wire is for a binary digit. If the digit is 0 the pin/wire is set to LOW, if it is a 1 it is set to HIGH. So for the number 7 the wires are LOW, HIGH, HIGH, HIGH.
  • These wires are soldered to the driver chip. The chip has 10 switches in it, one for each number in the Nixie Tubes. These switches are connected to the chips with yellow wires. The chips look at the 4 wires to see which binary number it is, and then switches on the correct light in the Nixie Tube.

The table below shows the wires and their values for each digit.

Digit Black Wire Blue Wire Grey Wire White Wire Binary

Here is the source code in C:

#include       /* These are libraries */

// turns a pin on or off
void nixiePin(int p, int v){

  if (p != -1) {
    digitalWrite(p, v);

// converts to binary and sends values to 4 pins
void nixiePins(int p1, int p2, int p4, int p8, int v){


// splits the time into digits
void nixieTime(int h,int m, int s) {

  nixiePins( 1, -1, -1, -1, h/10);  /* quotient of hour / 10  */
  nixiePins( 2,  3,  4,  5, h%10);  /* remainder of hour / 10 */
  nixiePins( 6,  7, 21, -1, m/10);  /* quotient of minute / 10*/
  nixiePins(22, 23, 24, 25, m%10);  /* remainder or min / 10  */

// makue sure all the digits work
void testClock(void){
  int i;
  for (i=1; i<=12; i++) {
  for (i=1; i<=59; i++) {

// set up the pins we will use
void initPin(int p) {
  pinMode(p, OUTPUT);
  digitalWrite(p, LOW);	

// this is the main part of the program
int main (void) {           
  time_t now;         /* its a variable that holds time info */
  struct tm *ntm;     /* it is a variable */
  int i;
  wiringPiSetup();    /* set up pins 0-7 and 21-29 to use  */
  for (i=0; i <=7;i++) {
  for (i=21; i <=29;i++) { 
  digitalWrite(0, HIGH);            /* turn on high voltage power */ 
  testClock();                      /* test all the digits */ 

  while (1) {                       /*starts and infinite loop */ 
    now=time(NULL);                 /* ask the computer for the time */ 
    ntm=localtime(&now);            /* it formats the time */ 
    if (ntm->tm_hour > 12) {        /* if hour is more than 12 - 12 */
      ntm->tm_hour = ntm->tm_hour-12;

    /* it tells it to write that number to the nixie tubes*/

    delay (1000);   /* wait for 1 second */


The Circuit Board:


My dad drilled a piece of plastic for me for the Nixie Tubes to sit on.

The circuit board has 4 Nixie tubes, and 4 chips (one for each).

The chips are wired to the Nixie Tubes with yellow wires.

Black wires are used for Ground, and red wires for 5 and 12 Volts. 5V and Ground was wired to each chip.

The Nixie Tubes require 170V DC to work, so in one corner I have soldered a high voltage power supply. This takes 12V and turns it into 170V. All 170V wires are green.

The Nixie Tubes need resistors attached to them, so they don’t take too much current and burn out. The resistors limit the current to 2mA.

There is also a Transistor with 2 more resistors to limit the current.  This transistor acts as a switch, and lets my program turn the High Voltage Power Supply on or off.

I also added a USB port, and wired it so it has 5V and Ground. This lets me use it as a power supply for the Raspberry Pi.

Then the inputs to the chips were wired to pins on the Raspberry Pi GPIO (see code for pin numbers).

Soldering took a very long time. Before we turned it on, my Dad checked over everything, making sure the 170V was safe. He found a couple of shorts that had to be fixed.

When I turned it on the first time, the tubes just half glowed and flickered. However if I took two chips out of the sockets, then the other two would work. This was because the 170V power supply wasn’t powerful enough. I double checked the datasheet, I should have been using about 1.5W, well under the 5W the power supply should be able to make from 5V. Instead of running the high voltage power supply on 5V, I tried 12V (it is rated up to 16V input), and that solved the power problem.

The Case:

I made a box out of wood and plastic. I got to use a big circular miter saw with my Dad supervising to cut the wood. The plastic is cut by using a sharp blade to cut into it, and then snapping it. Then everything was screwed together:


What’s Next:

I was very nervous about taking it into school – the last boy that took an electronic clock into school in Texas got arrested, so my Dad contacted the school first to let them know. I think my teacher was impressed, I had to explain everything in detail to her.

This is only the start of the project. I want to put it in a nicer case with my Dad’s help before I give it to my Mom. I want to add an alarm. I also want to add a hidden camera, microphone and speaker, so it can run voice/face recognition. Then I can turn it into J.A.R.V.I.S. from Ironman. That may take me a while, but I’ll add more posts on my blog as I do things to it.

Liz: Have you made a school project with the Pi that you’d like to share with us? Leave us a note in the comments!

The post Alex’s Nixie Clock appeared first on Raspberry Pi.

GPIO Zero: a friendly Python API for physical computing

via Raspberry Pi

Physical computing is one of the most engaging classroom activities, and it’s at the heart of most projects we see in the community. From flashing lights to IoT smart homes, the Pi’s GPIO pins make programming objects in the real world accessible to everybody.

Some three years ago, Ben Croston created a Python library called RPi.GPIO, which he used as part of his beer brewing process. This allowed people to control GPIO pins from their Python programs, and became a hit both in education and in personal projects. We use it in many of our free learning resources.

However, recently I’ve been thinking of ways to make this code seem more accessible. I created some simple and obvious interfaces for a few of the components I had lying around on my desk – namely the brilliant CamJam EduKits. I added interfaces for LED, Button and Buzzer, and started to look at some more interesting components – sensors, motors and even a few simple add-on boards. I got some great help from Dave Jones, author of the excellent picamera library, who added some really clever aspects to the library. I decided to call it GPIO Zero as it shares the same philosophy as PyGame Zero, which requires minimal boilerplate code to get started.


This is how you flash an LED using GPIO Zero:

from gpiozero import LED
from time import sleep

led = LED(2)

while True:

(Also see the built-in blink method)

As well as controlling individual components in obvious ways, you can also connect multiple components together.


Here’s an example of controlling an LED with a push button:

from gpiozero import LED, Button
from signal import pause

led = LED(2)
button = Button(3)

button.when_pressed = led.on
button.when_released = led.off


We’ve thought really hard to try to get the naming right, and hope people old and young will find the library intuitive once shown a few simple examples. The API has been designed with education in mind and I’ve been demoing it to teachers to get feedback and they love it! Another thing is the idea of minimal configuration – so to use a button you don’t have to think about pull-ups and pull-downs – all you need is the pin number it’s connected to. Of course you can specify this – but the default assumes the common pull-up circuit. For example:

button_1 = Button(4)  # connected to GPIO pin 4, pull-up

button_2 = Button(5, pull_up=False)  # connected to GPIO pin 5, pull-down

Normally, if you want to detect the button being pressed you have to think about the edge falling if it’s pulled up, or rising if it’s pulled down. With GPIO Zero, the edge is configured when you create the Button object, so things like when_pressed, when_released, wait_for_press, wait_for_release just work as expected. While understanding edges is important in electronics, I don’t think it should be essential for anyone who wants to

Here’s a list of devices which currently supported:

  • LED (also PWM LED allowing change of brightness)
  • Buzzer
  • Motor
  • Button
  • Motion Sensor
  • Light Sensor
  • Analogue-to-Digital converters MCP3004 and MCP3008
  • Robot

Also collections of components like LEDBoard (for any collection of LEDs), FishDish, Traffic HAT, generic traffic lights – and there are plenty more to come.

There’s a great feature Dave added which allows the value of output devices (like LEDs and motors) to be set to whatever the current value of an input device is, automatically, without having to poll in a loop. The following example allows the RGB values of an LED to be determined by three potentiometers for colour mixing:

from gpiozero import RGBLED, MCP3008
from signal import pause

led = RGBLED(red=2, green=3, blue=4)
red_pot = MCP3008(channel=0)
green_pot = MCP3008(channel=1)
blue_pot = MCP3008(channel=2)

led.red.source = red_pot.values
led.green.source = green_pot.values
led.blue.source = blue_pot.values


Other wacky ways to set the brightness of an LED: from a Google spreadsheet – or according to the number of instances of the word “pies” on the BBC News homepage!

Alex Eames gave it a test drive and made a video of a security light project using a relay – coded in just 16 lines of code.

GPIO Zero Security Light in 16 lines of code

Using GPIO Zero Beta to make a security light in 16 lines of code. See blog article here… http://raspi.tv/?p=8609 If you like the look of the RasPiO Portsplus port labels board I’m using to identify the ports, you can find that here http://rasp.io/portsplus

Yasmin Bey created a robot controlled by a Wii remote:

Yasmin Bey on Twitter

@ben_nuttall @RyanteckLTD pic.twitter.com/JEoSUlHtF6

Version 1.0 is out now so the API will not change – but we will continue to add components and additional features. GPIO Zero is now pre-installed in the new Raspbian Jessie image available on the downloads page. It will also appear in the apt repo shortly.

Remember – since the release of Raspbian Jessie, you no longer need to run GPIO programs with sudo – so you can just run these programs directly from IDLE or the Python shell. GPIO Zero supports both Python 2 and Python 3. Python 3 is recommended!

Let me know your suggestions for additional components and interfaces in the comments below – and use the hashtag #gpiozero to share your project code and photos!

A huge thanks goes to Ben Croston, whose excellent RPi.GPIO library sits at the foundation of everything in GPIO Zero, and to Dave Jones whose contributions have made this new library quite special.

See the GPIO Zero documentation and recipes and check out the Getting Started with GPIO Zero resource – more coming soon.

The post GPIO Zero: a friendly Python API for physical computing appeared first on Raspberry Pi.

Hour of Code 2015

via Raspberry Pi

Hour of Code is a worldwide initiative to get as many people as possible to have a go at programming computers.

Each December for the past couple of years, educators, tech businesses and non-profits alike have made a big push to get kids and adults to try their hand at writing a few lines of code. This year there’s a huge number of resources and projects available online, and schools all over the world will be taking part in what promises to be the biggest Hour of Code ever.

"Hour of Code" banner with children coding and egg timer

Here at Raspberry Pi Towers, we’re thrilled to play our part with a cracking selection of digital making projects for beginners and intermediate programmers.

Regular readers of this blog will know that we’re about to send Raspberry Pi computers to the International Space Station as part of Astronaut Tim Peake’s Astro Pi mission. You can find out all about the mission, and how you can get involved, on the Astro Pi website. As a special treat, we’ve included a selection of awesome space projects in our Hour of Code offering.

You don’t even need a Raspberry Pi computer to enjoy them. Our Gravity Simulator and Astronaut Reaction Time games both use the visual programming language Scratch, and while that works brilliantly on a Raspberry Pi, it works just as well on any old PC or Mac you’ve got lying about.

Two children wearing space suits play the Astronaut Reaction Time game, while floating in zero gravity!

Make a game in Scratch to test your reaction skills and see if you could become an astronaut

If you’re one of the 10,000 or so people who have got their hands on one of our lovely Sense HATs (that’s the add-on board with lots of sensors that we’re sending into space), then there are lots of cool projects for you. There’s a Minecraft Map and the wonderful Flappy Astronaut, which is not at all related to another game with a similar name (honest).

My personal favourite this year has to be the Interactive Pixel Pet project, which uses the Python programming language to transform your Sense HAT into an interactive companion. My eight-year-old son Dylan had no trouble completing it in an hour, although he’s spent a lot longer than that showing it off to his mates.

Dylan’s Hour of Code project

No Description

If none of those projects gets you excited, or perhaps when you’ve finished them all, head over to our resources section where there are dozens of excellent project ideas, lesson plans and much, much more.

You should also check out our community magazine, The MagPi, which brings you 100 pages of projects every month, and is always free to download as a PDF.

Whether you’re in a classroom or a bedroom, our job is to provide you with the tools, inspiration and support to learn about digital making. What are you waiting for?

Part of our Hour of Code page, showing a selection of Beginner and Intermediate resources

Hour of Code is a really important initiative, but anyone who tells you that you can teach someone how to code in an hour (or a day) doesn’t know what they’re talking about. What Hour of Code can do is help demystify computer science and spark an interest in learning more.

Initiatives like Code Club translate that interest into something more substantial, giving young people the knowledge and confidence to shape their world through code.

If Hour of Code inspires you, then why not get involved in setting up or running a Code Club at a primary school near you? Whatever your level of skills, giving just an hour a week of your time will make a huge difference.

The post Hour of Code 2015 appeared first on Raspberry Pi.

The Official Raspberry Pi Projects Book is out now!

via Raspberry Pi

Rob from The MagPi here again! Two posts from me in one week? You’re a very lucky bunch.

One thing we’re very proud of at The MagPi is the quality of our content: articles, features, tutorials, guides, reviews, inspirational projects and all the other bits and pieces that have made The MagPi great for 39 issues and counting. When we went back into actual print in a big way with issue 36, we had people asking us whether we’d ever release issues 31-35 as printed copies; we assume they wanted copies to frame and hang on their walls, or maybe to donate to a museum collection. Either way, we definitely haven’t been ignoring your cries.

A picture of the cover of the Official Raspberry Pi Projects book

200 pages. Dozens of articles. Out right this second.



Instead of releasing these individual issues in the Swag Store like in the old days, we decided to give them the shelf space in bricks-and-mortar shops that they deserved all along. So please welcome The Official Raspberry Pi Projects Book, packed with 200 pages full of the best projects, tutorials, reviews and much, much more, out right now for only £12.99!

You’ll find it in the magazine racks next to (or very near) The MagPi, and to be honest the image doesn’t do the cover justice. It’s beautifully glossy and slightly embossed. It’s definitely worth popping down to WHSmiths just to be dazzled by its glory.

Otherwise, you can grab a copy from the Swag Store, get a copy in our app available for Android and iOS, or grab the free PDF of the whole thing!

A picture of the contents spread of the Official Raspberry Pi Projects book

With almost 100 articles in the book, there are definitely a few things for everyone.
Click for a larger image.

Even if you’re not so bothered about completing your collection of The MagPi (however much it breaks my heart), this is a book with 200 pages of fantastic Raspberry Pi content that’s extremely handy if you want ideas for more awesome stuff to do with your Raspberry Pi. I’d like to point out that it’s a darn good stocking stuffer as well, what with it being only five weeks until Christmas and all.

We hope you all enjoy this book, however you plan to use it. And don’t forget to look out for our very exciting issue 40, out next Thursday. You absolutely will not want to miss it.

Anyway, on Monday I put a Picard gif at the end of the post. So here’s another. [This is a thing with Rob; we’re humouring him. Tell us in comments if you want us to make him stop – Ed.] See you next time!

The post The Official Raspberry Pi Projects Book is out now! appeared first on Raspberry Pi.

University of York: Raspberry Pi Challenge 2015

via Raspberry Pi

For the last three years I’ve been visiting the University of York Computer Science building on the last day of Freshers’ Week to see what the new entrants have been doing with Raspberry Pi.

York is using the Pi to help get the students started with computing (for those whose contact has been limited to tablets and desktops!) before they get to university: every year, they send a free Raspberry Pi to their new undergraduates who are about to start a Computer Science course, and support them to prepare for the Raspberry Pi Challenge. It also forms a great social event which gets the computer science students together (along with beery delights) to fight it out in the Pi Squared arena!

Raspberry Pi Challenge at York 3.0 2015

We’ve just held our third Raspberry Pi Challenge at York. Our new undergraduates receive a free Raspberry Pi when they confirm their place at York and have a month to do something creative or take part in our knock out competition. Here’s what happened in 2015. Would you like to take part in 2016?

Last year they used a version of Battleships to compete, but this year they’ve changed to Squares.  One of the great things about this game is that the simplest few lines of code can make a huge difference over the random player (simply iterating through all possible ‘walls’ and drawing one if it closes a box is a big improvement on drawing walls at random), but there is much more that can be done to improve and optimise the strategy (there is a time limit per move, so you are a little limited!).

If you’re interested in playing the game and writing an implementation yourself (or if you’re another university and you’d like to compete against York’s outstanding undergraduates), the code and documentation is all freely available on GitHub:


PiSquare – This is a python template allowing two Raspberry Pis to play against each other in a variant of the classic game “dots and boxes”. The game was used in the University of York Raspberry Pi challenge 2015.

As an alternative challenge, there is also the chance to compete in Blue Pi Thinking, which is an opportunity for the students to create something ingenious using a Raspberry Pi.  The results from this project have been quite amazing.

One student created a tabletop food ordering system using the Raspberry Pi touch display.  The idea is that the screen is embedded into the table at a fast food restaurant, and you can order your food and pay for it using NFC without actually having to leave your table!  I can’t wait to see the first fast food joint with fully integrated Raspberry Pi shopping!

Another student wanted to create a pill diary system for an elderly relative. Here the central idea was to create a simple schedule for the pills which would beep or flash when it was time to take a pill.  It also would have the ability to take a photo or a time-lapse video, so a family member or carer could check they were being taken correctly.

University of York Computer Science Raspberry Pi Challenge: an undergrad works on his entry to recreate photographed objects in Minecraft

The picture above is from one student who connected his camera to the Pi. His system would take a photo of a scene from four sides, and then recreate the object in Minecraft!

University of York Computer Science Raspberry Pi Challenge: an undergrad tests his entry to map the mood of Twitter on a map of the UK

The project shown above was created to map the mood of the UK.  It took Twitter feeds from around the country and used various recurring words and phrases to decide on the mood of people from different places, then displayed them on a map of the UK with different colours to indicate the mood.

University of York Computer Science Raspberry Pi Challenge: an entry to use Raspberry Pi to control solar tracking in a solar panel installation

Lastly, a project to demonstrate how a Raspberry Pi can be used to control a solar panel installation and track the sun!

Read more about the Raspberry Pi Challenge from York’s Department of Computer Science. They’re already thinking ahead to next year’s Challenge with a new group of first-year undergraduates – I can’t wait to see what the next lot get up to!

The post University of York: Raspberry Pi Challenge 2015 appeared first on Raspberry Pi.