Your shopping cart is empty!
Gesture Control With Maker Nano RP2040 And APDS9960
- Hussien Jawhar Sathik
- 03 Jun 2022
- Tutorial
- 1622
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
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
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
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."