Getting hooked on programming with YRS project ‘Hook’

Carrie Anne: A few weeks ago, Raspberry Pi hosted its first ever Young Rewired State centre and took part in the Festival of Code. We had a lot of fun. Our participants talked about their experience in this blog post. Whilst we were at the finals in Plymouth, our teams were competing against a group from BBC Birmingham mentored by our good friend Martin O’Hanlon, and their Raspberry Pi project blew us away. Here in their own words is a little more about it.

Not only functional, but stylish too!

Not only functional, but stylish too!

While taking part in the YRS Festival of Code at BBC Birmingham our team wanted to come up with something fun. The idea we finally settled on after much talk of boats and canals (thanks Martin!) was the internet enabled coat hook – a coat hook which would tell you what to wear that day based on the weather forecast.

Fuelled by an endless supply of biscuits and coffee at BBC Birmingham and with the help of our mentors we set about creating our ‘hack’. At the weekend down in Plymouth we were lucky enough to make it into the final three for the ‘Best in Show’ category, losing out to another team. However since we were runners up in the category we were rewarded with some limited edition Blue Raspberry Pis!

Our idea was well received throughout the weekend in Plymouth, but what surprised us most was the reception that it received online. Seeing people we’ve never met before announce online that they’d buy our ‘internet enabled coat hook’ that we’d hastily constructed a few days prior was the craziest part of the weekend.

Screenshot from 2014-08-10 213744

We’ve each written a short paragraph about our contribution to the ‘hack’ and what we learnt during the week.

Screenshot from 2014-08-15 193909 Screenshot from 2014-08-15 193840Jenny & Ed: Why did we use Lego to build the Hook? Because it’s a classic building material enabling the design of Hook to be easily changed during development, as well as being sturdy AND fun – no actually it was because Kevin (from YRS) promised cake to any teams that used Lego in their hack.

We built the Lego around the coat rack and then the LED chipboards to secure the whole thing together, originally using a breadboard to connect up the Raspberry Pi and the LEDs with crocodile clips, however we kept facing issues where the LEDs would not light up. We realised that this was because one of the clips wasn’t on properly or the pin in the breadboard was loose, so decided that it would be more secure and look better if we created an actual chipboard and soldered all the parts together: cue multiple expeditions down to the workshop and a lot of time bonding with the soldering iron (if you’ll pardon the pun). The building of the Lego structure took around half a day, not including the numerous heated discussions about which colour bricks to use, and then completing the circuitry meant we had a working prototype design only a couple of hours later.

Screenshot from 2014-08-15 193922Darci: I worked on the animation for our project (The Hook). To do this, the BBC gave us some prototype LED boards, which I programmed using a Scratch-like program. We were going to make weather-specific animations for wind, rain and sunshine, but as we only had four days to produce it, I ended up making one animation to show all of the weather animations together.

I started off figuring out how to control the LEDs using an Arduino, but then we all agreed that it would be better to use a Raspberry Pi rather than an Arduino because I find Python much easier to understand than Arduino, and we could also use the GPIO to hook up the LED devices to the Raspberry Pi. So, it seemed simpler to use the Raspberry Pi to control everything instead. I used Python and the RPi.GPIO library to write the code to allow the back end to control the LEDs.

Darci presents hook

Darci presents Hook

Screenshot from 2014-08-15 193944Cameron: I ended up working on the back end which was written in Python. It controls the obtaining and processing of the data from the Met Office and then runs lower level code written by Darci. The Met Office API was really nice and returns a Weather Type field in the JSON response which saved us having to come up with our own heuristic for what the weather will be like. The best take-away from this for me would have to be the program PuTTY which is a free SSH client for Windows that removed the need to connect anything except a Wi-Fi dongle to the Raspberry Pi. The JSON library for Python was very useful and easy to work with as well, something that’s well worth learning.

Screenshot from 2014-08-15 194010Jack: I worked on the front end of the website which allows the user to configure what item of clothing they wanted to place on each individual hook, which could potentially change depending on the time of year. In order to fetch relevant weather forecast data from the Python backend the user’s geolocation was fetched through the browser using JavaScript. Additional information such as the item of clothing on each hook was written to a text file, allowing it to be easily read by the Python script. We aimed to make the website responsive across multiple different screen sizes, so writing CSS media queries was a new skill I had to learn during the week. Luckily the good folks mentoring at BBC Birmingham were happy to show me the ropes.

YRS BBC Birmingham Team Hook

YRS BBC Birmingham Team Hook

Carrie Anne: Although this project did not win in its category, it could still win the public vote! If you are as impressed as we are with this project then head on over to the voting page to cast your vote for Hook!