Using the Kitronik Inventor's Kit With the Adafruit CLUE
Introduction: Using the Kitronik Inventor's Kit With the Adafruit CLUE
The Kitronik Inventor's Kit for the BBC micro:bit is a great introduction to microcontrollers with electronics using a breadboard. This version of the kit is designed for use with the inexpensive BBC micro:bit. The detailed tutorial book which comes with the kit includes MakeCode examples using Blocks and JavaScript equivalent code for the last few projects. This is more suitable for beginners and young children than C/C++ required for Arduino-style programming. Kitronik also provide MicroPython versions of the code on their web site under the Inventors Kit Additional Free Resources section.
The Adafruit CLUE is a more advanced derivative of the micro:bit with a faster processor, full colour 240x240 LCD screen, a compatible edge connector, more sensors and a tiny onboard speaker. The edge connector compatibility is an important feature and allows this board to be used with many existing products like the Inventor's Kit. The CLUE currently supports Arduino-style programming and CircuitPython. 1003
CircuitPython is a derivative of MicroPython - it's very similar but has a few differences, particularly around the libraries.
This project shows how to use CircuitPython libraries on the CLUE to emulate the micro:bit's microbit and music libraries. This allows the MicroPython code to run as-is for the ten projects in the Inventor's Kit and the two extra projects from the website. The CLUE could also be used by re-writing all the code in CircuitPython but this pair of libraries offers an immediate way to get started with the kit.
An enhanced display mode offers additional visualisation of the pins (pads) as they are read from or written to. This shows clearly how inputs and outputs are used which may enhance the learning experience.
Note: there is a different version of the kit available for the Arduino Uno or Maker Uno Plus: Kitronik Inventor's Kit for the Arduino.
Supplies
* Kitronik Inventor's Kit for the BBC micro:bit
* Adafruit CLUE
Step 1: Installing the CircuitPython Libraries
If the CLUE board does not already have CircuitPython on it then follow these instructions and a CIRCUITPY drive should appear. The version can be confirmed by inspecting the boot_out.txt file or connecting to REPL via the serial console over USB.
The following libraries need to be downloaded (right click and Save link as...) and placed in the lib directory on the CIRCUITPY drive.
* microbit.py
* music.py
* display_pin.py
The display_pin library is a dependency of the microbit library. The adafruit_display_text library is a dependency of the microbit and display_pin libraries and can be extracted from Adafruit's library bundle.
* Adafruit CircuitPython Library bundles - download this for adafruit_display_text library - the image above shows some other useful libraries which are needed if you want to use accelerometer, compass and display.read_light_level().
The following program can be downloaded to demonstrate some of the visualisation capabilities.
* microbitlibemu_simpletest.py
This needs to be placed in the top-level directory in CIRCUITPY and renamed to code.py.
Step 2: Connecting the Components
The aforementioned sample code is designed to be used with components connected to the micro:bit/CLUE as per Kitronik's Experiment 3. Kitronik's booklet shows how to connect these.
This is a summary of the components and connectivity.
* pin0 - a push button switch which connects the input to ground.
* pin1 - a 10k linear potentiometer.
* pin2 - a red LED with a 47k resistor in series.
* pin4 - a piezo speaker (this is not part of the original experiment but is useful to test the music library).
Step 3: Dimming an LED Using Pulse-Width Modulation
The CLUE program has been interrupted prior to the video using REPL via the serial console over USB. Control-D is pressed to exit REPL and start the code.py program.
The libraries are loaded first in the program:
from microbit import *
import music
Then "microbit" is displayed by scrolling in text view mode, followed by "library" in basic view mode (currently a bit sluggish), then "emulation on CLUE" in enhanced mode.
display.mode = "text"
display.scroll("microbit")
display.mode = "basic"
display.scroll("library")
display.mode = "enhanced"
display.scroll("emulation on CLUE")
display. 1003