Thursday, August 15, 2019

Trackbot (part 2: remote control with microbit bluetooth)

Again there was no specific plan here, just worked it out as i went along, meanwhile holding true to these objectives:
  1. Ideally, don't spend any money (use what i have already)
  2. Be able to control forward and reverse for each track.
  3. In case of having to spend money, make any spend as reusable as possible.
  4. Make it fun to use!  Lights!  Buzzers!
A commercial RC control was a non-starter due to rule number 1.  That being said i did find a nice tutorial about how to integrate one with an Arduino.

Next, i did have the two BBC micro-bit microcontrollers, and i knew that they both did bluetooth.  So i had an idea i could build up one as a transmitter/controller and the other as the receiver.  It turns out getting them talking isn't hard (at all) but i didn't want to use block code, nor even that online compiler thing.

So then i did some reading and discovered there are heaps of choices when it comes to where you code your microbit, including the Arduino IDE.  I had a wow moment at that point :) and quickly dipped into the wonderful world of microbit with the arduino ide thanks to Adafruit.  That short tutorial series completely changed my plans, and i learned:
  1. With the right resources we can achieve amazing things!
  2. That i can easily code microbit in the familiar arduino IDE ecosystem.
  3. When doing so i don't need to sacrifice core microbit functionality (like bluetooth or the other sensors etc).
  4. I don't need two microbits at all, because Adafruit has a BRILLIANT iOS app, and i can control the microbit from there!
  5. wow!
So.. that was a bit if a whirlwind, but as a result i then had a microbit with some wires hanging off it, some code largely based off the example, and an app with which i could trigger the microbit, it was perfect for my needs.

Microbit plus jumpers and power cable (to battery terminal).
I was able to then use the remote control app and hit a button, and the microbit would send one of those pins high.  I randomly picked them, but tested each pin in turn until they all worked.  Also soldering to a microbit is annoying.



I know I'm glossing over things a bit, but seriously that tutorial was awesome, go have a look.  So in essence my remote control setup works as follows:
  1. I power up the L298N which provides 5v to the Arduino
  2. The microbit is powered from the 3.3v supply on the arduino
  3. The microbit is paired with my iPhone
  4. I open the app, connect to the microbit and navigate to the Control Pad
  5. Hit one of the 4 numbered buttons, and one of those jumpers goes high.
  6. ..celebrate.  It was almost too easy.
I do note that i lost PWM control here, these are simply on and off signals.  I can deal with that, and can still code in some soft start stuff if i want.
 
Next is then coding the arduino to do sensible things with these inputs..

No comments: