013 - MakeCode MicroBit: Brickcell Gesture APDS9960
Table of Contents
APDS9960 Gesture Sensor
The APDS9960 is a digital RGB (Red, Green, Blue) and gesture sensor manufactured by Broadcom, now part of Avago Technologies. This sensor is designed to detect hand gestures, proximity, and ambient light, making it useful for applications such as touchless gesture-controlled interfaces in electronic devices.
It operates by emitting infrared light and measuring the reflection to detect hand movements. The APDS9960 is commonly found in consumer electronics and IoT devices, enabling touchless control and user interaction.
Hardware Instruction
Let's explore how to connect the Gesture Sensor module to a micro:bit microcontroller and utilize MakeCode for programming.
- Connect the Gesture Sensor GND pin to micro:bit GND pin.
- Connect the Gesture Sensor VCC pin to micro:bit 5V pin.
- Connect the Gesture Sensor serial data pin (SDA) to micro:bit pin 20.
- Connect the Gesture Sensor serial clock pin (SCL) to micro:bit pin 19.
- Leave the Gesture Sensor interrupt pin (INT) unconnected.
Software Instruction
Now, let's start programming the micro:bit to utilize the Gesture Sensor module.
- Login to https://makecode.microbit.org/ using your Microsoft account.
- Create a new project by clicking the "New Project" button. You may name it descriptively, such as gesture-apds9960-test.
- Click the "Extensions" block under the "Math" block.
- Type https://github.com/gbantique/brickcell-gesture-apds9960/ in the search bar.
- Select the brickcell-gesture-apds9960 from the search results. The "gesture apds9960" block should now appear under the Brickcell category.
- Copy the code provided below:
Brickcell.onGesture(BrickcellGesture.Down, function () {
serial.writeLine("down")
})
Brickcell.onGesture(BrickcellGesture.Right, function () {
serial.writeLine("right")
})
Brickcell.onGesture(BrickcellGesture.Up, function () {
serial.writeLine("up")
})
Brickcell.onGesture(BrickcellGesture.Left, function () {
serial.writeLine("left")
})
serial.setBaudRate(BaudRate.BaudRate115200)
serial.writeString("Setup starting...")
Brickcell.init()
- Open a Serial Monitor such as Termite Terminal App. Set the baud rate to 115200 bps.
Or you can make a copy of my created project in your MakeCode workspace:
https://makecode.microbit.org/S67898-45195-03980-78151/
Expected Result
If you carefully follow the provided instructions above, you should be able to view the detected gesture in the serial terminal. The baud rate should be set to 115200 bps.