Saturday 18 February 2017

Microbit controlled model mini

I recently found this RC model mini in a charity shop for a bargain price of 50p. There was no remote controller but the model itself had the all important motors (1 for steering the front wheels and 1 for driving the rear wheels).



I had previously hacked a smaller RC car for use with an Arduino, but this time wanted to try out the BBC micro:bit. As it was half term, I roped my son into helping me, especially with some of the fiddly connections and soldering (my eyesight not really being up for the job).

First, he took it apart being careful to reserve screws and take photos as he went along. Once inside, we then identified all the important electrical connections we needed and removed the existing circuit board leaving as much of the wiring as we could.



Next began the gradual process of reworking and testing the model.

Our plan was to use the existing battery box to power the motors, but for the Micro:Bit to control them via an L298N H-bridge motor driver (which we already had). The Micro:Bit would have its own power supply (2 AAA batteries).

Plan of the final circuit

The motor power supply

The battery box (accessible from underneath) was a little corroded in places and the on/off switch was stuck in the on position. We cleaned everything up, but decided to ditch the switch and remove the existing wiring. The good news was that the battery compartment was for six AA batteries which meant there would be plenty of power for use with the H-bridge.

We tested the end to end connection with a volt meter and soldered on two good lengths of wire - black for -ve and red for +ve.

Locating good points to solder on the +ve and -ve wires

The motor connections

For each motor, we identified the two wires required to activate them. We then gave them a quick test by temporarily connecting them in turn to the battery box. All was fine.

As usual in toys of this sort each motor had a capacitor (or two) connected in parallel; we left these in place. The wires looked long enough to use directly so we just used some solder to tin them ready for connection to the H-bridge.

Locating the two wires connected to the rear wheels

Wiring up and testing the H-bridge

The four motor wires and the two wires from the battery compartment were connected to the H-bridge as follows:

The positions marked 1,2,3 and 4 are the signal pins to which the Micro:Bit would be later connected. However, rather than bring the Micro:Bit into the mix at this stage I got my son to simulate its action by a second circuit driven by 2 AA batteries, connected as follows.




He used an old Snap Circuits battery box for this and just moved the +ve connection to each of the signal pins in turn.

Note that the two circuits have the GND connection in common.

Once this had been tested we put the mini away and concentrated on the Micro:Bit side of things.

Accessing and programming the GPIO pins of the Micro:Bit

We were going to need four of the Micro:Bit pins for our project which meant purchasing an edge connector board. We opted for this one from Kitronik

Edge Connector Breakout Board

There are lots of options for programming the Micro:Bit. I opted for the Microsoft PXT using the block editor as this seemed to fit our purposes best. I aimed for us to control our car from an Android phone over bluetooth and this project provided clear instructions and a ready made app.

A simple LED circuit



As my son was new to the Micro:Bit and its programming environment I got him to connect up a simple LED circuit and make sure he understood the build and download process. When this code is loaded the LED lights if Button A is pressed and goes off when it is released.


Once this was working via a button press I got him to move on to getting it to work remotely via a smartphone using bluetooth.

Controlling the LED from the Android App

We downloaded the Android App which we planned to use to control our car. Full information on how to write code for the Micro:Bit which responds to events from this app can be found at the Kitronk Blog. (We used Bitty Software's dedicated Bitty Game Controller App rather than the general Microbit Blue App, but the principles and event numbers are the same.)

Bitty Game Controller's DPad with event names marked

Following the instructions, it was very simple to put together the code necessary to connect to the Micro:Bit and to remotely activate the LED by pressing button 1 on the DPad:

This code provides visual confirmation of our connect / disconnect status

This code handles the events sent when button 1 is pressed on the DPad
After testing the connection to the Android App my son then extended the circuit to include four LEDs and added the rest of the code. We could now operate four LEDs via the forward/reverse and left/right buttons on the Android App.

The only complication was having to re-pair the Android device with the Micro:Bit every time we had downloaded new code over the USB connection. You do get used to doing this, but at first it was frustrating.


Attaching the Micro:bit to the mini's motors via the H-Bridge


After testing the code with the LEDs we were ready to attach the Micro:bit to the motors.

We attached the jumper wires from the Micro:bit pins to the H-Bridge pins. We tested each connection via the app as we went along to make sure each game control button activated the correct motor and direction. No adjustment was required to the code at this stage.

Connecting the microbit to the H-bridge and testing
The Micro:bit was then connected to a battery box and we were ready to put everything back together.

Putting things together

This was probably the most difficult part of the project as my son was insistent that none of our mods should be visible once the car body was back in place. For me, the important constraints were no risk of short circuits and the ability to easily disconnect both power supplies.

H-Bridge connected and secured in position
After some carefully placed velcro, bluetack, foam sheets and sticky pads we managed to squeeze everything in, replace the body and screw it back into position.

Microbit secured

Battery compartment attached to the top for easy access
The very top part was just slotted in and allowed easy access to the inside.

Closing the hatch
Ready for the test drive!

The Test Drive





The power to the motor driver is cut by detaching a connector. The power to the microbit is cut by a switch on its battery compartment. Both of these have easy access. What doesn't have such easy access is the ability to pair the microbit. Fortunately, once your code is loaded and you have already paired with a device it is not something you have to do again as the Android device will remember. But changing to a different Android device will probably require unscrewing a few things.

Still, not a bad half term project.

Thursday 9 February 2017

Printable soft circuits for Arduino, Microbit and Raspberry Pi

Image of an embroidered design printed onto cotton
The following idea developed out of a secondary school Creative Computing club I helped run. I had read that one way to engage more girls in coding was with e-textiles so I looked into ways that we could incorporate this into our club.

I have seen some impressive e-textile creations online but many of these involve significantly more sewing than actual coding. I was concerned that by introducing e-textiles to the club we would end up with students spending most of their time sewing rather than forging ahead with more challenging coding concepts.

I wanted something in kit form, with minimal sewing but which introduced students to the potential of e-textiles and soft circuits. It also had to be cheap as we had very little budget. Basically I was after a printable textile equivalent of kits such as this Christmas Tree kit:


Pi Hut's Christmas Tree Kit

or even better, something like this e sewing template from Spark Fun
Lilypad e sewing kit
So, I turned to my old friend - a stack of inkjet T-shirt transfer paper - which I have called upon for many projects over the years. I found a suitable Christmas Tree Image online to which I added the following:
  • LED positions
  • resistor positions
  • guidelines for conductive thread
  • external connection positions
The image was then reversed,



printed onto T-shirt transfer paper, cut out and ironed onto white felt. Here is the finished article.

Completed Christmas Tree
I sewed this myself and presented it to the students as one of many ready-made projects for which the coding was the main goal. Another example was this training shoe:

Trainer Light Sequencing Project
And here are a couple connected up to a BBC microbit:




Once completed, these e-textiles were easy to store, reusable and robust.

Not only is this technique useful for introducing e-textiles it also provides an alternative to breadboard circuits and commercially made projects such as traffic light add-ons.

No special electronic components were used, just cheap LEDs and resistors which were attached with conductive thread. There are plenty of instructions elsewhere online as to the best way to sew these on. I use long nose pliers to twist the ends into loops, but scissors also work. Here are some of my efforts:





And for the terminals, I use small coils of copper wire. These can be attached easily to crocodile clips or to jumper wires:



Saturday 4 June 2016

An Arduino Controlled Cyber Pet


As a volunteer in a creative computing club I was looking for ideas to inspire students and came across a collection of school project kits based on the PICAXE microcontroller.

One of the more interesting projects describes uses of microcontrollers in popular cyber toys such as the Furby. Here are some extracts from the manual for that project:


the inner workings of a Furby


Although we were working with Arduinos, much of the information provided for PICAXE microcontrollers applies equally to the Arduino and this looked like an excellent project to inspire my students.

And for anyone looking for clear descriptions of basic electronic components and microcontroller interfacing circuits the PICAXE manuals are brilliant.

So, I set about creating a cyber pet of my own using the components we were teaching the students about and the craft materials we had available. For the body of the pet I used a cheap soft toy dog (from a charity shop). Here is a video of the finished result:




The following components were used:

  • 2 LEDs for the eyes
  • 1 reed switch in the nose
  • 1 light emitting diode (LDR) in the head
  • 1 servo motor mounted on k'nex in the body
  • 1 piezo module attached directly to the Arduino
  • several resistors
The arduino and battery pack were hidden in the body.

As I had not soldered before I chose to use conductive thread to attach and link components.

LEDs, resistors, LDR and the reed switch were all attached to the inside of the head with conductive thread which was then attached to insulated wires. This required some thought in order to avoid short circuits. All of the sewing was within the head of the toy which was filled with stuffing. The circuit was planned out in advance of any sewing with components being added gradually and tested as I went along: 

planning out the circuit

The servo motor was mounted on a k'nex structure. This required creating extra screw holes in two orange pieces of k'nex. A lolly stick was attached to the servo arm to provide a mechanism for moving the head. 
k'nex motor support
Servo motors are great for beginners as they contain their own driver and can be connected directly to the Arduino. The motor I used was a tiny towerPro SG90; these are available very cheaply. The disadvantage of servos is that most are not continuously rotating, but for projects such as this they are perfect.

The finished cyber pet was used as a demo when introducing students to the project part of the club. I had also picked up a couple of Furbys in a charity shop as examples of very sophisticated commercially available cyber pets, but which included many of the components we were learning about:

demo furby

dissected furby
This turned out to be a popular choice of project for the students over the last few weeks of the club. Unfortunately time was very limited and most students only got as far as adding a motor to their own soft toys (enabling them to wag tails, nod heads etc.) but they all enjoyed the experience and hopefully got a feel for how commercial toys are developed.

Sunday 3 April 2016

Creative Computing with the Arduino - experiences of a school club

Last year I volunteered on a Creative Computing project with Science Oxford. Myself and a fellow STEM ambassador ran a lunchtime club in a local secondary school with kit kindly donated by The Royal Academy of Engineering.







First Time Experiences

The first week was about getting to grips with the arduino, a breadboard and a simple LED circuit.


The Blink Circuit


The Blink Sketch

For the next few weeks we introduced basic programming concepts and a few simple electronic components. This was very successful, with most students being able to complete the weekly set task within the short lunch break.



Simple Tone Generator




For the final few weeks we encouraged the students to work on a project of their own, using the programming concepts and components they had learned about. We gave them a few ideas and lots of craft materials to work with. This was based on the success of a few workshops that had been run previously in the school holidays.


Animating a soft toy

In terms of production, the project weeks were less successful, with few students completing anything they set out to achieve. I think the main reasons for this were:
  • time required for setting up and tidying away eating into useful project time
  • C/C++ being a difficult language for beginners
  • wider mix of abilities and ages compared to the holiday clubs
  • our inexperience of teaching
  • too many different projects on the go at once, too much freedom
  • students preferring to spend time constructing the craft element, rather than doing any programming
This was a little disheartening. However, the school was delighted with our efforts and we were invited back to run a second club. I was pleased to see some of the original students returning for more in addition to several new faces.

However, we were now faced with the problem of some students being total beginners and others having already done the taught part of the club. In addition, we wanted to improve on the less successful 'project' part of the club.

Improving Our Efforts

We decided to stick with the taught part. But for the project weeks I devised a number of ready made projects complete with guidelines on connecting and programming (but not full solutions). Students who had been with us before were allowed to work on the projects from the first week or re-do any parts of the taught weeks.


trainer light sequencing

plush toy mood lamp

This worked well on the whole, and was much better than the free for all of the first club. The ready made projects were less of a step up from the taught component of the club and students had more of a sense of achievement at the end. In addition, managing students working on familiar projects was a lot easier, particularly as I was the only STEM ambassador available for much of this club. It also meant we didn't have to store several crates worth of craft materials.



In Conclusion


This was a very rewarding experience but I did feel that the weekly sessions were too short and that this would have been better run as a series of after school workshops (maybe 2 hours each session). Having to disconnect everything at the end of a session was frustrating. Just getting a student back to where they had been the week before could take up half the session. And they had to eat their lunch whilst at the club.

However, I was very impressed with the robustness of the Arduinos as they certainly were not treated with kid gloves! Not one of them failed. But the programming language (C/C++) proved too much for many students, especially as few had programmed before (not even in Scratch). 

What Next?

The BBC recently launched the micro:bit:


I am looking forward to when the micro:bit becomes available to the general public and hope to adapt some of the Arduino projects that came out of this club. From what I can see, it will be a much easier platform to get started with compared to the Arduino.


Wednesday 14 January 2015

Keeping my Joggler going with the new Tesco API

Joggler - an organiser for busy families


Back in 2009, O2 launched the Joggler. The adverts caught my eye and the product looked interesting (this was before the days of the Ipad and other such tablets). But at close to £150 I was not prepared to buy one. Nor were many other people it would seem as a year later the price dropped drastically to £50 and O2 sold off the remaining stock. At this point, I bought one on ebay and it has lived in my kitchen ever since.
Joggler Squeezeplay - awesome
It is mostly used as a controller for my music system, but its other main purpose has been as a shopping basket for my Tesco account. You see, once the Joggler arrived, I couldn't resist tinkering with it and its arrival coincided nicely with Tesco's launch of its API for third party developers.

Although this was my first experience of a web API and terms like JSON and REST were all new to me, I found the reference guide provided by Tesco to be excellent and knocking up a useable app was a breeze. The hardest part was getting my elderly version of Flash/ActionScript to run on the Joggler, but I got there in the end.
My Joggler App

It was great. When I ran out of something in the kitchen I just tapped on my Tesco favourites and added the item to my basket ready for my next order. This simple app has served me well for the best part of 5 years. As has the Joggler, despite its regular dusting of flour, icing sugar, butter and everything else that has been thrown at it.

But, after the Christmas and New Year break I went to add something to the basket and .... nothing. No service. Now I do vaguely remember reading somewhere that the service was going to be discontinued but .... did nothing.

Fortunately, all is not lost as Tesco appear to have been busy re-branding and the old techfortesco has become
http://www.tescolabs.com/
complete with new API. Yay!

So, I signed up for a dev key, fired up Flash 5 and fixed up my app to access the new API. Fortunately most of the commands that I use (LOGIN, LISTPENDINGORDERS, LISTBASKET, LISTFAVOURITES, PRODUCTSEARCH) all worked seamlessly. CHANGEBASKET however doesn't appear to do anything; the response tells me that 'Basket change completed successfully' but when I request the basket via LISTBASKET, nothing appears to have been added. I have a very vague recollection of this problem happening the first time around. Perhaps it just hasn't been implemented yet. I will wait before investigating my app further, but not for too long as I'm about to run out of tea and I really can't let that happen.

Any sane person may be wondering why I stick with the Joggler. I have asked myself that many a time. In fact, last year, I was all set to replace it with my Asus EEpad with its lovely big screen. However, that died completely after less than two years of ownership and very little use - and it cost about 10 times the price of my trusty old Joggler! So cross. I am reluctant to splash out on another tablet just for the kitchen, especially as it will have to be sticky finger proof, something that thankfully the Joggler has already proved to be.