Wednesday, January 16, 2013

Messing with a remote control car and some transistor

As per a previous post I have arranged a Raspberry Pi event (Raspberry Jam) at Gartner's offices in Egham on Sunday the 20th January.

Originally I was considering setting up my Raspberry Pi on a big screen with the Atari 2600 emulator running and a joystick for some old school nostalgia gaming but then I thought that might be a bit boring.

Since I have volunteered to run a Code Club at my kids school I thought how about something in Scratch.  Code Club uses Scratch and Raspberry Pi has  Scratch so if I did something in Scratch then I could have it at the Raspberry Jam and then also show it to the kids at a future date as an example of what is possible with Scratch.

Code Club does programming I thought maybe something with electronics and since I have an old cheap remote control car gathering dust I thought I'd try to design a switching circuit that would allow the Raspberry Pi to control the car from within Scratch.

My knowledge of Scratch, GPIO and Python are limited so it was lucky that somebody far smarter than me has developed the code to allow Scratch to control the GPIO pins. All the details at this link -  http://cymplecy.wordpress.com/2012/08/26/scratch-controlling-the-gpio-on-a-raspberrypi/
After figuring out I needed the latest image of Raspbian for this code to work I was off.
I did the obligatory flash an LED to make sure it all worked on the Raspberry Pi and it did.

Confident that Scratch could control the GPIO pins I turned my attention to the no name, small, cheap remote control.
Out with the multi-meter to check where the switches went to and how they were wired to the one IC on the board. I figured out that the pins are all held high and then go low to be actioned.
The remote from my testing old uses 0.1mA so it probably would have been safe to just attach it to the Raspberry Pi, but not sure if this was correct I decided to put in a transistor switching circuit that would hold the line high until a high is applied to the GPIO pin for that control and then it would go low. Effectively enabling that button on the remote and sending the relevant signal to the car.

I used a 2N222a NPN transistor for the circuit and again being concerned that my very rusty electronics would fail me I posted to the Raspberry Pi Forum asking if the design was OK including a small circuit diagram.(http://www.raspberrypi.org/phpBB3/viewtopic.php?f=44&t=29730) and amazingly Gert van Loo the Gertboard guy replied saying the circuit was good with a recommendation to add a 10K resistor from the GPIO to ground so the GPIO pins start in a determined state. (Yes, I'm missing a 2 in the image I'll fix it later)

With my head swelling from Gerts positive comments but still not ready to test with my precious Raspberry Pi that I needed for Sunday (plan B of Atari 2600 is still an option) I wired up the circuit to my Arduino who's pins a bit more robust.

Created a small bit of  code that set the pins high and low to see if it responded.

RESULT - the car went, forward, backwards, turned left, turned right.all controlled by the Arduino code

This means the circuit is good.  The electronics of the transistor switches works with the cheap remote  control.

So, tomorrow (Thursday) evening I will wire it to my Raspberry Pi and see if the final product works and then can I control it in Scratch.

If yes, then I will have it with me on Sunday.

Roll on tomorrow evening and roll on Sunday.


2nd Code Club lesson - experience and thoughts


After the first week where only 4 kids turned up this week was a different experience with 11 kids.  Of which 5 were boys and the rest were girls.  So, a nice mix.
The folders I gave the kids the last time were a big hit.  2 of the girls had decorated their folders and some of the new kids had been told about by others what happened the last time and were looking for their folders. 12p folders from the pound shop make you a hero.

The second lesson is the Whack a Witch class where the kids make a similar game to Whack a Mole but with witches. This class can be be downloaded from the www.codeclub.org.uk website. The final words 'look like this' are the link.

Wit most of the kids having missed the first session I had to go through some of the fundamentals with them but didn't want to lose the excitement and moment of actually doing so I gathered them around one computer and showed them the stage, sprites, and the other bits at a really high level, knowing this wouldn't be enough for them to work on their own but hopefully would give them some comfort with the interface.

What followed was a manic hour of excited kids and a whole lot of one-on-one guidance.
But this time by the end all kids had the game completed.  Some with more support than others, but they all had their game to play and enjoy.  One of the girls who was there last week got it done in about 20 minutes and even started helping others. I think I have found my future helper.  Nothing proves you have learned something than being able to show others. I made a point of telling her mother when she was being collected how great she was and how helpful she was with the others just starting.

I provided a letter for kids that I found here (http://andrewjohns.net/blog/2012/12/a-letter-to-parents-regarding-scratch/) to take home for their parents if they wished to explain to their parents what they are doing and also ask to have Scratch installed on their home computers.

Once again the time felt way too short. It's either me or the sessions should be 90 minutes so I've asked the teacher coordinating if we can run the sessions from 3:20 - 5:00.  Giving 10 minutes at the start and then 90 minutes of mad activity.

When the kids had gone and we were back in the class tidying up a great thing happened. Another teacher came in and said while she was in her class she heard 2 boys outside saying how great the club was. Really enthusiastic and excitedly.  So, even though the class was a bit rushed and the learnings were limited due to the speed the No.1 objective I hope for was achieved. The kids were excited and eager to do more.  The learning and understand will come once they master the interface and repeat some of the steps.

So, another successful(ish) Code Club. Roll on next week and the fireworks.



Saturday, January 5, 2013

Egham/Staines Raspberry Jam 20th Jan 2013

Back in October I started the process of hosting a Raspberry Jam at my employers office in January.
It took nearly 2 months to get it sorted but we got there and on the 20th of December I announced the first Raspberry Jam at the Gartner offices in Egham on the 20th of January 2013.

In case you're unaware a Raspberry Jam is an event for people interested in the Raspberry Pi computer. An opportunity to meet like minded people and hopefully get inspired or connect with people who are looking to achieve the same or similar goals to yourself.

I attended a couple at Bletchley Park in Milton Keynes in October and November and was even more convinced that Raspberry Jams were a great idea and well worth organising.

Well, with 2 weeks to go there are only 3 tickets let of the 50 allocated on Eventbrite. http://eghamraspberryjam.eventbrite.com

There 2 confirmed presentation, including the amazing near space live images project Pi in the Sky.

Based on the demand so far I'm hoping for a full house and if this one goes well I will work to get it set up so we can have Raspberry Jams regularly at the Gartner offices.

A big thank you to Alan O'Donohoe  @teknoteacher for getting the ball rolling with the Raspberry Jams and also for talking to me about what is involved in preparing a successful Jam.

Here's looking forward to the 20th of January and a successful Raspberry Jam.