Learn electronics, coding, and projects — step by step.

013 - MakeCode MicroBit: Brickcell Gesture APDS9960

George Bantique October 17, 2023 No Comments

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.

  1. Connect the Gesture Sensor GND pin to micro:bit GND pin.
  2. Connect the Gesture Sensor VCC pin to micro:bit 5V pin.
  3. Connect the Gesture Sensor serial data pin (SDA) to micro:bit pin 20.
  4. Connect the Gesture Sensor serial clock pin (SCL) to micro:bit pin 19.
  5. Leave the Gesture Sensor interrupt pin (INT) unconnected.

Software Instruction

Now, let's start programming the micro:bit to utilize the Gesture Sensor module.

  1. Login to https://makecode.microbit.org/ using your Microsoft account.
  2. Create a new project by clicking the "New Project" button. You may name it descriptively, such as gesture-apds9960-test.
  3. Click the "Extensions" block under the "Math" block.
  4. Type https://github.com/gbantique/brickcell-gesture-apds9960/ in the search bar.
  5. Select the brickcell-gesture-apds9960 from the search results. The "gesture apds9960" block should now appear under the Brickcell category.
  6. 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()
  1. 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.

×

Leave a Reply

Required fields are marked *






Related Articles: (by Categories)