Gesture Control With Maker Nano RP2040 And APDS9960

Introduction

In this tutorial today, we shall see how to interface Maker Nano RP2040, APDS 9960 and servo motor to perform a gesture control

Video

Hardware Preparation

For this tutorial we will need the following components

dcim101mediadji 0277.jpg
DCIM\101MEDIA\DJI_0277.JPG

Building The Circuit

To interface all the components together, i have decided to built a simple circuit on a donut board. The circuit is as shown below

untitled sketch schem

Please do note that the Arduino shown in the image above is the classic Arduino Nano. I have this, because there is no library for Maker Nano RP2040 yet inside the Fritzing.

Code

Below is the complete code that we have used in this tutorial

#include "Adafruit_APDS9960.h"
#include <Servo.h>
Adafruit_APDS9960 apds;
Servo myservo1,myservo2;

// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(115200);
  myservo1.attach(2);
  myservo2.attach(3);
  if (!apds.begin()) {
    Serial.println("failed to initialize device! Please check your wiring.");
  }
  else Serial.println("Device initialized!");

  //gesture mode will be entered once proximity mode senses something close
  apds.enableProximity(true);
  apds.enableGesture(true);
}

// the loop function runs over and over again forever
void loop() {
  //read a gesture from the device
  uint8_t gesture = apds.readGesture();
  if (gesture == APDS9960_DOWN) 
  {
    Serial.println("v");   
    myservo2.write(0);   
  }
  if (gesture == APDS9960_UP) 
  {
  Serial.println("^"); 
  myservo2.write(180); 
  }
  if (gesture == APDS9960_LEFT)
  {
  Serial.println("<");
  myservo1.write(180); 
  }
  if (gesture == APDS9960_RIGHT) 
  {Serial.println(">");
  myservo1.write(0); 
  }
}

Thank You

Thanks for reading this tutorial. If you have any technical inquiries, please post at Cytron Technical Forum.

Please be reminded, this tutorial is prepared for you to try and learn.
You are encouraged to improve the code for a better application.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Detect RGB Color With Raspberry Pi Pico
Build an IoT Project Using LoRaWAN Network with Cytron LoRa-RFM Shield and Helium Console
Measure Soil Moisture Sensor Using Raspberry Pi Pico And Maker Soil Moisture Sensor
Getting Started Raspberry Pi Compute Module 4 Lite And Mini Base (A) Board (CM4-IO-BASE-A)
Measure The Ambient Temperature With Raspberry Pi Pico And Grove Temperature Sensor Using Arduino IDE
Tutorials of Cytron Technologies Scroll to Top