Menu
Microbots
0
  • Make
    • Getting Started
    • Maker Builds
    • Education
  • Shop
    • Maker-Modules
    • Maker-Packs
    • Tools & Gears
    • Robots & Displays
  • About
    • Our Story
    • Reach Out
    • FAQs
  • English
  • Your Cart is Empty
Microbots
  • Make
    • Getting Started
    • Maker Builds
    • Education
  • Shop
    • Maker-Modules
    • Maker-Packs
    • Tools & Gears
    • Robots & Displays
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Language

  • 0 0

CodeCell: Depth Gestures

In this build, we'll explore how to use the CodeCell's onboard proximity sensor to detect depth gestures and control two FlatFlaps, varying their angles based on the proximity values. This project demonstrates a unique way to create interactive robots, actuators, motors or light that respond to hand movements.


What You'll Learn

  • How to set up the CodeCell for depth gesture recognition using its proximity sensor.
  • How to control two FlatFlaps using proximity data from the CodeCell.
  • An understanding of how to integrate the tiny DriveCell, to control FlatFlaps.

About the CodeCell's Proximity Sensor

The CodeCell is equipped with a VCNL4040 proximity sensor that can measure distances up to 20 cm. By using an infrared light, the sensor detects objects within its range, measuring the reflection of emitted IR light to approximate distance. This allows you to create responsive behaviors based on how close an object is, making it ideal for interactive gestures.

Depth gestures are based on the proximity data from the CodeCell's onboard sensor. By moving your hand or other objects closer or further from the sensor, you can create dynamic inputs that drive various actions. In this project, the proximity data is used to control the angle of two FlatFlaps, which are connected to two DriveCells (H-bridge drivers). 

Project Overview

In this example, the CodeCell continuously reads proximity data and adjusts the angle of two FlatFlaps based on how close the object is. As the object moves closer or further, the angle of the FlatFlaps changes, demonstrating a simple yet effective method for depth gesture-based control.

The two FlatFlaps, are soldered to two DriveCells (H-bridge drivers), which are pin to pin compatible with the CodeCell. These components are then connected on 3D printed mount, to create a cute little Flappy-Bot! Don't forget to add a googly-eye to give it more personality!

Below is the example code to get you started. Ensure your CodeCell is properly connected via USB-C, and the FlatFlaps are connected to the two DriveCells. Follow the comments in the code to understand each step.

Example

#include <CodeCell.h>
#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6

DriveCell FlatFlap1(IN1_pin1, IN1_pin2);
DriveCell FlatFlap2(IN2_pin1, IN2_pin2);

CodeCell myCodeCell;

void setup() {
    Serial.begin(115200); // Set Serial baud rate to 115200. Ensure Tools/USB_CDC_On_Boot is enabled if using Serial.

    myCodeCell.Init(LIGHT); // Initializes Light Sensing

    FlatFlap1.Init();
    FlatFlap2.Init();

    FlatFlap1.Tone();
    FlatFlap2.Tone();
}

void loop() {
    if (myCodeCell.Run(10)) {
        // Runs every 100ms
        uint16_t proximity = myCodeCell.Light_ProximityRead();
        Serial.println(proximity);
        if (proximity < 100) {
            // If proximity is detected, the FlatFlaps flap
            FlatFlap1.Run(1, 100, 400);
            FlatFlap2.Run(1, 100, 400);
        } else {
            // Adjust FlatFlap angle based on proximity
            proximity = proximity - 100;
            proximity = proximity / 10;
            if (proximity > 100) {
                proximity = 100;
            }
            FlatFlap1.Drive(0, proximity);
            FlatFlap2.Drive(0, proximity);
        }
    }
}

Tips for Customization

  • Adjust Thresholds: Modify the proximity thresholds and scaling factors in the code to fine-tune the responsiveness of the FlatFlaps based on your preference.
  • Expand Functionality: Consider adding more CodeCell sensing functions, like motion tap detection or light sensing to add more functionality to your Flap-Bot!
  • Create Custom Designs: Use 3D printing to create a more unique robot, making it more personalized.

Conclusion

This project shows how to use the CodeCell's proximity sensor for depth gestures, driving the angles of FlatFlaps based on object distance. Experiment with the code, customize the parameters, and bring your own flappy bot to life!

  • Share:

Follow

Github

  • About
  • Software
  • Education
  • Contact
  • FAQs
  • Terms
  • Refund Policy
  • Privacy Policy

Join our Community ~ Be the first to know about new products and get exciting deals!

© 2025 Microbots.