Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO-Based Gesture and Voice-Controlled Servo with Security Keypad

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Gesture and Voice-Controlled Servo with Security Keypad

Circuit Documentation

Summary

This circuit is designed to interface with various components including an APDS9960 gesture sensor, an Arduino UNO microcontroller, a servo motor, a voice recognition module, a 4x4 membrane matrix keypad, and LEDs (red and blue). The Arduino UNO serves as the central processing unit, controlling the servo motor based on input from the keypad, voice commands, and gesture detection. The LEDs provide visual feedback, and the piezo buzzer can be used for audio signaling.

Component List

APDS9960 Gesture Sensor

Arduino UNO

Servo Motor

Voice Recognition Module

4x4 Membrane Matrix Keypad

LED: Two Pin (Red)

LED: Two Pin (Blue)

Piezo Buzzer

Wiring Details

APDS9960 Gesture Sensor

Arduino UNO

Servo Motor

Voice Recognition Module

4x4 Membrane Matrix Keypad

LED: Two Pin (Red)

LED: Two Pin (Blue)

Piezo Buzzer

Documented Code

#include <SoftwareSerial.h>
#include "VoiceRecognitionV3.h"
#include <Arduino_APDS9960.h>
#include <Servo.h>
#include <Keypad.h>
#define ROW_NUM    4  
#define COLUMN_NUM 4 

Servo myservo;
char keys[ROW_NUM][COLUMN_NUM] = {
  {'1', '2', '3', 'A' },
  {'4', '5', '6', 'B' },
  {'7', '8', '9', 'C' },
  {'*', '0', '#', 'D' }
};

byte pin_rows[ROW_NUM] = {4, 5, 6, 7}; 
byte pin_column[COLUMN_NUM] = {8, 10, 11, 12}; 
Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM);

const String password_1 = "123AA"; 
const String password_2 = "5678BC";   
const String password_3 = "77657";    
String input_password;

int angle = 0; 
unsigned long lastTime;

VR myVR(2, 3);    
uint8_t records[7]; 
uint8_t buf[64];

int led = 13;

#define onRecord    (0)
#define offRecord   (1) 

void printSignature(uint8_t *buf, int len)
{
  int i;
  for(i=0; i<len; i++){
    if(buf[i]>0x19 && buf[i]<0x7F){
      Serial.write(buf[i]);
    }
    else{
      Serial.print("[");
      Serial.print(buf[i], HEX);
      Serial.print("]");
    }
  }
}

void printVR(uint8_t *buf)
{
  Serial.println("VR Index\tGroup\tRecordNum\tSignature");

  Serial.print(buf[2], DEC);
  Serial.print("\t\t");

  if(buf[0] == 0xFF){
    Serial.print("NONE");
  }
  else if(buf[0]&0x80){
    Serial.print("UG ");
    Serial.print(buf[0]&(~0x80), DEC);
  }
  else{
    Serial.print("SG ");
    Serial.print(buf[0], DEC);
  }
  Serial.print("\t");

  Serial.print(buf[1], DEC);
  Serial.print("\t\t");
  if(buf[3]>0){
    printSignature(buf+4, buf[3]);
  }
  else{
    Serial.print("NONE");
  }
  Serial.println("\r\n");
}

void setup()
{
  input_password.reserve(32); 

  myservo.attach(9);
  Serial.begin(9600);
  while (!Serial);

  if (!APDS.begin()) {
    Serial.println("Error initializing APDS-9960 sensor!");
  }

  Serial.println("Detecting gestures ...");

  myVR.begin(9600);
  
  Serial.begin(115200);
  Serial.println("Elechouse Voice Recognition V3 Module\r\nControl LED sample");
  
  pinMode(led, OUTPUT);
    
  if(myVR.clear() == 0){
    Serial.println("Recognizer cleared.");
  }else{
    Serial.println("Not find VoiceRecognitionModule.");
    Serial.println("Please check connection and restart Arduino.");
    while(1);
  }
  
  if(myVR.load((uint8_t)onRecord) >= 0){
    Serial.println("onRecord loaded");
  }
  
  if(myVR.load((uint8_t)offRecord) >= 0){
    Serial.println("offRecord loaded");
  }
}

void loop(){
  char key = keypad.getKey();

  if (key) {
    Serial.println(key);

    if (key == '*') {
      input_password = ""; 
    } else if (key == '#') {
      if (input_password == password_1 || input_password == password_2 || input_password == password_3) {
        Serial.println("The password is correct, rotating Servo Motor to 90°");
         
        digitalWrite(led, HIGH);
        delay(3000);

        digitalWrite(led, LOW);

        lastTime = millis();
      } else {
        Serial.println("The password is incorrect, try again");
      }

      input_password = ""; 
    } else {
      input_password += key; 
    }
  }
  int ret;
  ret = myVR.recognize(buf, 50);
  if(ret>0){
    switch(buf[1]){
      case onRecord:
        /** turn on LED */
        digitalWrite(led, HIGH);
        delay(3000);
        digitalWrite(led, LOW);

        break;
    }
  }
  if (APDS.gestureAvailable()) {
    
    int gesture = APDS.readGesture();
    if (gesture == GESTURE_UP){
      digitalWrite(led, HIGH);
      delay(3000);
      digitalWrite(led, LOW);
    }
    myservo.write(90); 
    
  }
  
  char