Monday, September 10, 2018

DF Robot micro:Maqueen Robot For BBC Micro:Bit (programmed with the Arduino IDE)

DF Robot micro:Maqueen Robot
For BBC Micro:Bit (programmed with the Arduino IDE)
Sep 10, 2018



Prerequisites:
  1. Arduino IDE 1.8.x (recommend 1.8.5) installed and setup for your machine. https://www.arduino.cc/en/Main/Software
  2. Install the Arduino-nRF5 board core. Follow the instructions here: https://github.com/sandeepmistry/arduino-nRF5
  3. Install the Adafruit Micro:Bit Library: https://github.com/adafruit/Adafruit_Microbit and learn more about it here:  https://learn.adafruit.com/use-micro-bit-with-arduino
  4. Finally install the arduino-BLEPeripheral library (either from the library manager or by following instructions here: https://github.com/sandeepmistry/arduino-BLEPeripheral  ) * Note be sure it’s the one from sandeepmistry if you are using the library manager *
  5. NewPing Library (Which I believe is this library) https://github.com/eliteio/Arduino_New_Ping and is only needed if you are going to use an ultrasonic.

For this project you will need at least one Micro:Bit Controller:

And the Maqueen Robot chassis: https://www.dfrobot.com/product-1783.html

The Micro:Bit is setup to use Microsoft:MakeCode or Scratch and Python.
The Sandee P Mistry Board core lets us use this board with the Arduino (C style) language as well.

General Information:
I used the general information that is found either in the Maqueen MakeCode library on the board itself, or from trial and error to come up with something that works (mostly) with the Arduino IDE.

Working (or mostly working):
  1. Motors (I2C interface, easier to port than I thought it would be)
  2. Line Sensors (P13, P14)
  3. Ultrasonic (using newping library) P1, P2 * Attempted to get this working without the library, but it failed (????) *
  4. 2 LEDs P8, P12
  5. Buzzer P0 - *  tone is not yet implimented with the board, analogWrite works but doesn’t sound great, bit bang also works, but doesn’t sound great - this is in the mostly working columb)
What’s not working: (These things work if you use MakeCode, but so far I’m unable to get them to work with Arduino).
  1. NeoPixels (P15 4 pixels) - The Adafruit Neopixel library appears to be the only library that supports the Micro:bit, this isn’t surprising. But I’ve not been able to get it work on P15, it does work on P2 which is what the example provided is using. https://learn.adafruit.com/micro-bit-lesson-3-neopixels-with-micro-bit/software
  2. IR receiver (P16) - so far I am unable to get this to work at all - *I need something that doesn’t mess with interrupts or timings, but I think that is a big ask for this device*
  3. Communication between two Micro:bit controllers - It’s a bit upsetting to me that such a basic thing was neglected in the Arduino IDE (If this does work, and you have supporting code please share - I have not been able to get this to work, or find any code that claims it works) ** This is a basic thing in the MakeCode, I’ve not been able to find the library they use or information about how they make it work **  https://learn.adafruit.com/micro-bit-radio-controlled-puppet/code-the-two-micro-bits    


Basic Sketches:  (To be duplicated)
  1. Drive and turn - (done) I2CMotortest, I2CMotortest2
  2. *RGB Breathing Ambient Light - unable to complete at this time.
  3. LED Light Flash - (DONE) - blinkdemo
  4. Read Ultrasonic Distance  (*DONE*) - They output to the LED Matrix, I output to the Serial console of the Arduino IDE (Easy to change as needed) newping
  5. *Read Infrared Key Assignments - unable to complete at this time. *
  6. *IR Remote Control - unable to complete at this time*
  7. Line Tracking - Currently Working on it.
  8. Ultrasonic Obstacle Avoiding - (DONE) - avoid
  9. Light Operated Sprite (unsure about this one)
  10. Wireless Remote Control  - * They are using a Micro:bit Gamepad (see below), I believe I can make this work with the Tablet and Adafruits Bluefruit LE Connect software * This is a work in progress.

The compass and accelerometer on the Micro:bit also work, as well as the LED Matrix and the two buttons on it.  *The Compass is in the wrong orientation to be used as a true compass, but it maybe able to be used to do relative positions, I will have to test that more.*

I am in the process of making a library and attempting to duplicate the applications in the DF  Robot wiki. It is not even close to being ready. I’ll post a link when it is ready.

DF Robot also provided a Micro:Bit Gamepad for use with this project, the gamepad has 8 buttons total (various P#s), a LED on P16, buzzer on P0, and a vibration motor on P12
Button assignments:
DOWN  - P13
LEFT - P14
UP - P8
RIGHT - P15
X - P1
Y - P2
A - P5
B - P11

This was very easy to port over to the Arduino IDE, the buttons are all HIGH until they are pushed then they go LOW.
I may not be able to use this as intended because I am having problems getting two Micro:bit to communicate directly with each other.

A game or something may be coming thou...we will see