Introduction: Using the Cytron Edu:bit With the Adafruit CLUE
The Cytron Edu:bit is a new kit designed for children as an introduction to programming and physical computing using the BBC micro:bit. The colourful tutorial book (126 pages) has ten projects using block-based MakeCode making it suitable for young children. The board supports 3 servos and 2 motors using 5V power and comes with a servo and a small motor. The board has a thoughtful design for beginners to electronics with clear labelling, LEDs to the show the digital and analogue signal levels and four buttons to test or drive the motors manually.
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 Edu:bit and Kitronik Inventor's Kit. The CLUE currently supports Arduino-style programming and CircuitPython. CircuitPython is a derivative of MicroPython - it's very similar but has a few differences, particularly around the libraries. This project shows how the CLUE can be used with the Edu:bit. Cytron's ten projects are not replicated in CircuitPython, instead some other programs are shown which demonstrate use of the Edu:bit using the CLUE's screen. A CircuitPython version of the Edu:bit's MicroPython library facilitates this.
The Edu:bit has a clever design where the seven sub-boards ("Bits") are connected physically but can be snapped off and then reconnected using Grove cables. Seven 20cm (8in) Grove buckled cables are supplied. There is also an eighth Grove connector and a double female socket providing access to the i2c bus with 3.3V power. This allows for more advanced use with a variety of Seeedstudio and third-party boards. The MicroElectronicDesign tinyLiDAR, a time-of-flight (ToF) sensor with Grove connector, features in this article.
The Edu:bit is powered using a barrel connector and comes with a special USB Y cable to provide both power from a host computer and data connectivity to the micro:bit or CLUE.
I backed the Kickstarter campaign for the Edu:bit (ends 22nd October 2020) as they looked like great Christmas gifts. The board in this article is a sample Cytron kindly sent to me to let me test compatibility and usability with the CLUE - it's identical to the production version.
Step 1: Plotting P0, P1 and P2
The video above shows a program plotting the analogue values from the P0, P1 and P2 inputs. The Edu:bit's connectivity is:
- P0 - Music Bit - this is actually an output so won't show anything useful!
- P1 - Sound Bit - sound level, appears to be most sensitive to bass sounds and impact like tapping.
- P2 - Potentio Bit - a linear potentiometer, turning to the right increases output voltage from 0V to 3.3V. Note: the seven segment bright blue LED ring also indicates this value.
The program can be found in Adafruit Learn: CLUE Sensor Plotter in CircuitPython.
Step 2: An Audio FFT Spectrogram With Peak Meter
This program makes use of the CLUE's onboard microphone to record sound samples and then process them with the ulab library (a cut-down numpy) to show the different audio frequencies within the sample in a spectrogram. The process is continuous but the sampling and processing operate sequentially without an overlap so it can miss very short transient sounds.
The program is based on FFT Example: Waterfall Spectrum Analyzer from Adafruit Learn: ulab: Crunch Numbers fast in CircuitPython with some additional code to:
- illuminate the green, yellow and red large LEDs for sounds which have loud bass, mid or treble components;
- use the 4 RGB pixels as an audio level peak meter using the value from the Edu:bit's Sound Bit.
Step 3: A Sweeping LiDAR Using TinyLiDAR With I2c Grove Connection
This program sweeps the servo back and forth with the tinyLiDAR mounted on top with some blue tack. The servo is connected to S3 (yellow/orange to S, red to +, brown to -) and the tinyLiDAR is using one of the Grove cables that comes with the Edu:bit.
The distance measurements are converted with the servo angle from polar coordinates to a cartesian format to draw decaying green dots on the screen for any objects within range. On the viewer's left is a small cardboard cat from the Edu:bit materials and a micro:bit in an orange case is on the right. The cased micro:bit moves slowly out of range during the video. The actual range of the tinyLiDAR is 2 metres (6ft) but it's restricted here to show more detail for near objects and avoid clutter.
The code can be found on edubit-lidar-servo-distance.py. This program could be enhanced in various ways.
- The Edu:bit LEDs could highlight when a target is near to the LiDAR sensor.
- The potentiometer could be used to control the distance range or sweep angle.
- The speaker could be used to play sounds as the LiDAR sweeps and/or if a target is found.
- The graphics could be improved. Michael Bottin has a nice example of a similar scanning LiDAR on Adafruit CLUE nRF52840 & CircuitPython - LIDAR RADAR (YouTube).
Step 4: Microbit Emulation Library Showing 6 Pins
This program uses the microbit and music emulation libraries developed for Instructables: Using the Kitronik Inventor's Kit With the Adafruit CLUE. This is probably not the first choice of libraries for programming the Edu:bit with the CLUE but it does show the visualisation of the pin values on screen, a similar idea to the bright blue LEDs on the Edu:bit board.
The first part of the short program shows a few images and some text and plays a short sound-effect on the default pin, pin0. The Edu:bit has pin0 connected to the Music Bit - the music will play on its speaker or the 3.5mm socket depending on the switch setting. The mono signal goes to both left and right channels.
from microbit import * import music display.mode = "text" display.show(Image.SMILE) sleep(1000) display.show(Image.HAPPY) music.play(music.POWER_UP) sleep(1000) display.mode = "enhanced" display.scroll(" CLUE with Edu:bit ") sleep(2000)
while True: p1 = pin1.read_analog() # Sound Bit p2 = pin2.read_analog() # Potentio Bit p8 = pin8.read_digital() # IR Bit # 3 LEDs R, G, B pin14.write_digital(int(p1 > 200)) pin15.write_digital(int(p2 > 512)) pin16.write_digital(p8)
Step 5: CLUE Vs Micro:bit
The micro:bit is a good choice for the Edu:bit. It's very good value for money, it has all the features needed for the board and it has a rich ecosystem and a large userbase.
The CLUE's primary advantage with the Edu:bit is its colour LCD display. It may also be useful for Bluetooth Low Energy (BLE) programming. The CLUE does not currently (October 2020) support MakeCode leaving a choice of CircuitPython or C/C++ for Arduino-style programming.
The new micro:bit V2 will be another option when it's generally available.