Last Saturday we had a look at how we might figure out how far and how fast a bike is going using a Raspberry Pi. We used a very basic set up with just a micro-switch attached to a toy trike with a little nut taped to the front wheel, each time the wheel rotates the nut would “click” the micro-switch.
We would need to use a reed switch or a hall effect sensor and a magnet attached to the wheel if we were to use this on a real bike.
We started of our coding by looking at the time.time() function. This function returns the number of seconds, in decimal form, since 01 January 1970. If we want to time an event all we have to do is use time.time() to get the start time and use it again to get the end time and then subtract the the start time from the end time.
We used this to get the the amount time it takes to do one rotation. Now we want to find out how many rotations we have per minute or RPM (revolutions per minute). As our result is in seconds the easiest thing to do is calculate revs per second so we divide 1 by the time it takes to do 1 rotation and then multiply the answer by 60 to get RPM.
Now we wanted to get KPH(kilometres per hour) so first we measured the circumference of the wheel and found it was 50cm or 0.5 Metres. We then calculated metres per minute by multiplying our RPM by 0.5 and we then multiplied this by 1000 to get KPH.
Here’s a picture of what our results could look like when displayed using Pygame. We will look at Pygame later on as it’s an excellent way of displaying information.
Last week in the Bodgers group we began by looking at our new keyboards and Touchscreens. These will allow us to easily design touch based projects and projects that need a monitor. They will also be invaluable at the start of next years sessions as we can get our code on the Raspberry Pi straight away without any need to connect our laptops.
We also started planning our next project with a short brainstorming session and we have a couple of ideas we will develop further this week.
I was away this weekend so Dave looked after the group.
He covered some basic electronics theory such as Ohms Law, how we use resistors in our circuits to protect other components and how to wire up an LED. He also helped the group build a simple traffic light circuit controlled by an Arduino which they then programmed.
The Raspberry Pi Foundation have announced that they are not running the Pioneers Challenge this year and are instead concentrating on the Coolest Projects. This means that Coolest Projects is now open to Code Club and Raspberry Jam members. There will be a UK Coolest Projects in April in London and Coolest Projects in Dublin will now be called Coolest Projects International. See more info here.
We have two sessions before the mid-term break so we will concentrate on coming up with ideas for our next projects and how we might implement these ideas and that will leave us a couple of weeks to get components etc. organized.
This week we continued to play with the Sense HAT and as we’ve been mostly focusing on projects so far this year we took the opportunity to look at some of the theory behind programming.
We looked at how we use variables, loops and decisions in our programs and we also learned about algorithms. An algorithm is a set of rules we can use to solve a problem for example an algorithm to determine if a given year is a leap year. A year is a leap year if it is divisible by four, but not by one hundred, unless it is divisible by four hundred.
We then worked on a program which would allow us to “move” an LED around the LED matrix on the Sense HAT. You can run our code on the trinket.io Sense HAT emulator.
Dave will lead the group next week when he will cover some basic electronics.
It was great to see everybody back after the break.
I had a big box of goodies from the recent Raspberry Pi Pioneers competition. We got more swag for both teams that entered including some very nice badges and three really interesting books.
Our Zombie Trolls also got their prize for failing really well 😊. This included a Raspberry Pi, a 5” HDMI Monitor, some basic electronic components, t-shirts and an Astro Pi Sense Hat (Hat stands for ‘Hardware Attached on Top’).
The Sense HAT add-on board was specially created for the Astro Pi competition which gives kids the chance to get their code running on one of two Raspberry Pi devices that are on the International Space Station.
The board gives Astro Pi the ability to ‘sense’ and make many kinds of measurements, from temperature to movement, and to output information using a special display – the 8×8 LED matrix. We had great fun playing around with the Sense Hat and it’s definitely something we will get great use out of and maybe we could enter the Astro Pi competition and have our code running on the ISS.
We also took a look at controlling an Arduino from Unity 3D which is something that could be used for 4D/Immersive Technology type game.
I didn’t realize when I posted yesterday that the results of the Pioneers Challenge were out today.
Here is the Raspberry Pi Blog post announcing the winners.
Congratulations to Barry, Kevin and Zack the Zombie Trolls whose project Zombie In The Middle won the We Appreciate What You’re Trying To Do prize. the following is a quote from the website.
“Playing piggy in the middle with zombies sure is a unique way of saving humankind from total extinction! We loved this project idea, and although the Zombie Trolls had a little trouble with their motors, we’re sure with a little more tinkering this zombie-fooling contraption could save us all.”
Well done to the three boys and well done to all the Bodgers because all the Pioneers teams helped each other out, most importantly at the beginning when we were trying to come up with ideas for our entries.
Last Saturday we finished up for the break with our Christmas party. We played video of the projects we entered in the Raspberry Pi Foundation’s Pioneers Challenge “Only You Can Save Us”. The challenge involved teams working on projects that would help people if there was a zombie apocalypse.
We then gave everyone an opportunity to have a go at a robot wars style game with our Raspberry Pi robots.
Happy Christmas Everyone, we’re really looking forward to next year and building more cool stuff.
This weekend in the Bodgers Group our three Raspberry Pi Pioneers teams continued to work on their projects.
The Zombie Herders were working on a PIR (passive Infra-red) sensor which is the type of sensor commonly found in burglar alarms.
They used the GPIOZero library for Python and sample code which can be found here. However they didn’t have much success so we need to do more testing on our sensor and if necessary order a new one.
The zombie trolls worked on creating a 3-D model for their project using FreeCAD which they will print out when we return after the break.
I’m afraid I not allowed to discuss what it will be used for at this point :-).
Team Green Fingers worked on more scripts for their project including using their Arduino and a relay to switch a 12 volt automobile bulb on and off.
As with most projects like this we had a little trouble getting it going as we forgot to set the pin we used on the Arduino as an Output. Thanks to James and his Dad for bringing in the 12 volt powerpack.
We are off for the next two Saturdays and we’re back again on the 11th of November.
There was great excitement at this weeks session as the Pioneers teams opened their gifts from the Raspberry Pi Foundation. Each team member received a Raspberry Pi USB wristband, a Pioneers Lanyard, stickers and some sweets. Each team also got a copy of the Makers Guide to the Zombie Apocalypse and some zombie make-up.
We also got to see what was in our “Mystery Box” and I’m sure we are going to get great use out of it in future projects.
We then talked about the videos we’ll need a part of our entry and we had a look at a video from Pioneers on we need to put in our videos.
Then the teams spent some time planning out what they are going to do for their films.
Next week we are going to get back to working on our our projects.