I received a micro:bit board for testing for a week, killed it the next day (http://microworldtour.github.io/microbit/mahiri.html), received another one and build some robots with it (http://microworldtour.github.io/microbit/monifa.html).
A simple robot based on the BBC micro:bit.
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
I received a micro:bit board for testing for a week, killed it the next day (http://microworldtour.github.io/microbit/mahiri.html), received another one and build some robots with it (http://microworldtour.github.io/microbit/monifa.html).
ere's the exploded view:
And the connections:
Once I had the mechanics done, I started to work on the programming. Setting the speed of the servos was easy enough:
import microbit
microbit.pin0.set_analog_period(20)
microbit.pin0.write_analog(int(25 + 100 * degrees / 180))
But then making it turn exactly 90° or travel exactly 10cm required some careful experimentation with timing.
Once I had that, hooking up the distance sensor was easy. It's an analog SHARP range finder, so all I needed was to read the analog pin. Then I added some simple logic for finding out in which direction the obstacle is further away, and voila, object avoidance:
And that's it. All the code sits in the repository: https://bitbucket.org/thesheep/micro-bot/src
I knew what I wanted to do with the micro:bit -- I wanted to put it into robots and program them in Python. So I decided to start with the simplest thing possible -- a two-wheeled robot, with continuous rotation servos and a caster wheel. I only had two criteria for choosing the parts:
I started by gluing everything together with the two-sided tape in several different configurations. At the beginning, I didn't have the white depron bar to hold the screws, so I simply hotglued them to the servos:
This is actually the only interface the robot has with the micro:bit, because I didn't have the edge connector for accessing all the other pins yet. But three pins is enough for me -- two for the servos, and one for the distance sensor.
After assembling and testing it with some simple code, I noticed that the servos have a lot of problems with the PWM signal generated by the micro:bit. They would basically rotate at maximum speeds in random directions... So I went to the nearby hackerspace and used their oscilloscope to look at the signal. Turns out that you have to set the frequency of the PWM signal several times for it to have the desired effect. After just one time, the frequency is off by an order of magnitude:
But then if you actually start sending a signal and set it again, it becomes correct:
Well, correct apart from some twitching, and it would still change directions randomly. Since I couldn't find the reason for that in the signal, I turned to the power. And yes, replacing the two alkaline AAA batteries with a 3.7V LiPo battery solved that problem.
Create an account to leave a comment. Already have an account? Log In.
Become a member to follow this project and never miss any updates
nice one. oh... and there's glue: 10 bonus points :)