Tag Archives: computer science

Desktop Sense HAT emulator

via Raspberry Pi

If this post gives you a sense of déjà-vu it’s because, last month, we announced a web-based Sense HAT emulator in partnership with US-based startup Trinket.

Today, we’re announcing another Sense HAT emulator designed to run natively on your Raspberry Pi desktop, instead of inside a browser. Developed by Dave Jones, it’s intended for people who own a Raspberry Pi but not a Sense HAT. In the picture below, the sliders are used to change the values reported by the sensors while your code is running.


So, why do we need two versions?

  • For offline use, possibly the most common way Raspberry Pis are used in the classroom.
  • To accommodate the oldest 256 MB models of Raspberry Pi which cannot run the web version.
  • To allow you to integrate your Sense HAT program with any available Python modules, or other Raspberry Pi features such as the Camera Module.

The emulator will come pre-installed in the next Raspbian release but, for now, you can just install it by typing the commands below into a terminal window:

sudo apt-get update
sudo apt-get install python-sense-emu python3-sense-emu python-sense-emu-doc sense-emu-tools -y

You can then access it from the Desktop menu, under Programming.

The emulator closely simulates the Sense HAT hardware being attached to your Pi. You can read from the sensors or write to the LED matrix using multiple Python processes, for example.


Write your code in IDLE as before; there are also a number of examples that can be opened from the emulator’s built-in menu. If you then want to port your code to a physical Sense HAT, you just need to change




at the top of your program. Reverse this if you’re porting a physical Sense HAT program to the emulator, perhaps from one of our educational resources; this step isn’t required in the web version of the emulator.


There are a number of preferences that you can adjust to change the behaviour of the emulator, most notably sensor simulation, otherwise known as jitter. This costs some CPU time, and is disabled by default on the low-end Raspberry Pis, but it provides a realistic experience of how the hardware sensors would behave. You’ll see that the values being returned in your code drift according to the known error tolerances of the physical sensors used on the Sense HAT.

This emulator will allow more Raspberry Pi users to participate in future Astro Pi competitions without having to buy a Sense HAT: ideal for the classroom where 15 Sense HATs may be beyond the budget.

So, where do you start? If you’re new to the Sense HAT, you can just copy and paste many of the code examples from our educational resources, like this one. You can also check out our e-book Sense HAT Essentials. For a complete list of all the functions you can use, have a look at the Sense HAT API reference here.

You can even install this emulator on other types of Linux desktop, such as Ubuntu! For more information on how to do this, please visit the emulator documentation pages here.

The post Desktop Sense HAT emulator 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.