Johnny 5 is alive
Most of you will know that I work in a library. I’m a librarian (the clue is in the blog title) and it’s not really any secret that I’m a bit of a tech geek.
The other day I received an email from one of our grownups asking if I’d be up for a day workshop. The workshop was at C4di – the swanky new Centre for Digital Innovation in Hull – and involved the building of a robot in a day.
Sign me up. I’m in. Yes please.
The workshop was run by a gentleman called Rob Miles, some time lecturer at Hull Uni, Microsoft MVP and general all round tech guru. He’s even got a Wikipedia page! (https://en.wikipedia.org/wiki/Rob_S._Miles).
We met at 9am at C4di with the objective of building a robot in a day. A Hull Pixelbot to be concise. Check out the microsite for more info here (http://www.robmiles.com/hullpixelbot/).
A bit of a chat and a few bad jokes later we were ready to go. The group of attendees was a bit of a mix, a couple of young men who were still at school, a group of trainee teachers, a few tech guys from C4di and me.
The general plan was this. We were Rob’s guinea pigs. He’d set up some instructions and given us all a pack of parts. We were to build a robot following the instructions at our own pace and he and a colleague (thankfully also called Rob) would be on hand to help out when we got stuck.
Bag of goodies
Simples (as some TV animals would have us say).
So, given our bag of goodies, and access to the wifi and instructions we set off on our adventure.
First things first. Get the instructions up on my screen, and get the parts out of the bag.
First of all, let’s get this out of the way. Yes, I’m a librarian. Yes, I’m stupidly annoying with my organising, just ask Claire.
So obviously, my next step was to knoll the bag of goodies.
This pleases me
For those not in the know, knolling is that thing where you take all the parts and lay them all out together in an organised layout so you can easily find what you need next. Most useful when building Lego or doing something with lots of small parts. Apparently I’ve done this for years. Even when building flat pack furniture.
So…. off we go.
Working through Rob’s instructions I used the provided tools to bolt the bits of 3D printed plastic together.
A couple of circuit boards to control the motors and my robot looked like this.
A few more wires to add…and a battery pack on the underside.
Then the motors.
The next step is then to add the arduino. An arduino is a small computer. It’s similar to the Raspberry Pi, but is designed more for prototyping and creating something that powers other things. In this case controlling the motors. It’s cheap and easy to use (apparently).
The offending switch
So, add the wheels (complete with rubber bands to help with grip) and arduino, wire it all up and fix the power switch. I had a bit of an issue with the power switch. I spent an age trying to make it fit through the hole in the nice red plastic without snapping it. Embarrassingly, the switch simply unscrewed and fitted in about 10 seconds.
Eventually I got there. I’m sure my experience with the Pi and my limited home automation helped with the wiring and meant that I didn’t struggle as much as others in the room. Ironically the person who looked like they were having the most fun was one of the young guys who had never done anything like this before.
He was loving every minute of building the robot and seeing how the wires went and why.
The next step was to connect it up to my laptop and to start looking at how we could make the robot move.
I connected it up, and downloaded the software and fired up the development engine.
Step 1 of the coding instructions (which you can see in the screen grab above) was to send power to the motor control chips, making the LEDs flash. YES! This meant everything was wired up correctly. Success.
Next up. Lunch. We had to stop to go and eat. Forced to in fact, as Rob literally had to tell everyone in the room to stop and go out for something to eat.
*Trudges off to eat lunch*
Upon my return the instructions called for more coding. This time to make the robot move.
More coding and learning about the pickiness of coding in C followed. I’ve never used C in any shape but my basics in python and linux bash helped a lot with this. In fact, as much as I hate to admit it, those A level classes in pascal all those years ago came in handy.
After a bit of tinkering and head scratching… my robot moved. Forwards and backwards.
Here’s a short video of my robot, now christened Johnny 5 for obvious reasons.
Once we had made our robots move forwards and backwards it was time to add some sensors. One pair of eyes later and Johnny 5 looked even more like his namesake.
More coding, and learning about how the sensors work (it’s to do with one ‘eye’ sending out an ultrasonic sound and the other ‘eye’ being a microphone and listening for that sound bouncing back – but it’s too science-y for my understanding properly)
These sensors can help us to check for obstacles in the way of Johnny 5. Telling him to stop when it detects something was a simple matter, getting him to react and take avoiding action was much more complicated.
Eventually, I had Johnny stopping and turning to avoid something. However, he wouldn’t turn enough to avoid the object. He’d turn about 20 degrees and I wanted more to avoid things like walls.
However, our time at C4di was up. We’d run out of time in our ‘day’ for building a robot, but we had succeeded. Everyone had got a moving robot and some had succeeded in collision detection. Feedback for Rob was unanimous – the day was a success.
So home I go, taking Johnny 5 with me.
I’m not beaten yet though.
Upon arriving home I fired up the laptop and continue working on the code. I wanted Johnny to be able to avoid a wall. If only to be able to add a duster to him and have him sweep the living room floor.
An hour so so later and I had some limited success. Johnny now avoids the walls better than he did. I’m still not happy but he does avoid the wall…
I’m happy enough with his avoidance routines to take him along to the Raspberry Jam at the weekend to show him off.
No idea what is next, but it’s going to be fun finding out what else I can do with him. As we finished Rob told us about a hardware group that meet at C4di once a fortnight. I can see myself joining them to teach Johnny new tricks and to learn more about hardware hacking and coding.
I have succeeded in both making Johnny turn slightly more than a full 45 degrees so he is *much* better at avoiding stuff now. Plus, it occurred to me at the RaspberryJam this morning that he can only turn right. Now he can turn both left or right entirely of his own choice. Well, a random number generator makes the choice, but it’s close enough.