Hi guys
I have taken the 9 gesture sample & modified/trimmed it to the following. The eventual goal is to drive a servo.
The sensor is connected to UNO's 3.3v supply.
The code works for the first minute ot 2 & then stops working.
Not sure what i am doing wrong.
#include <Wire.h>
#include "paj7620.h"
/*
Notice: When you want to recognize the Forward/Backward gestures, your gestures' reaction time must less than GES_ENTRY_TIME(0.8s).
You also can adjust the reaction time according to the actual circumstance.
*/
#define GES_REACTION_TIME 600 // You can adjust the reaction time according to the actual circumstance.
#define GES_ENTRY_TIME 1000 // When you want to recognize the Forward/Backward gestures, your gestures' reaction time must less than GES_ENTRY_TIME(0.8s).
#define GES_QUIT_TIME 1200
int posServo = 90;
void setup()
{
uint8_t error = 0;
Serial.begin(9600);
Serial.println("\nPAJ7620U2 TEST DEMO: Recognize 9 gestures.");
error = paj7620Init(); // initialize Paj7620 registers
if (error)
{
Serial.print("INIT ERROR,CODE:");
Serial.println(error);
}
else
{
Serial.println("INIT OK");
}
Serial.print("servo int at: ");
Serial.println(posServo);
Serial.println("Please input your gestures:\n");
posServo = 90;
}
void loop()
{
uint8_t data = 0, data1 = 0, error;
error = paj7620ReadReg(0x43, 1, &data); // Read Bank_0_Reg_0x43/0x44 for gesture result.
if (!error)
{
//Serial.println (data);
switch (data) // When different gestures be detected, the variable 'data' will be set to different values by paj7620ReadReg(0x43, 1, &data).
{
case GES_RIGHT_FLAG:
delay(GES_ENTRY_TIME);
Serial.println("Right");
if(posServo <= 180)
{
posServo += 90;
Serial.print (" Servo: ");
Serial.println(posServo);
}
break;
case GES_LEFT_FLAG:
delay(GES_ENTRY_TIME);
Serial.println("Left");
if (posServo > 0)
{
posServo -= 90;
Serial.print (" Servo: ");
Serial.println(posServo);
}
break;
}
} else {
Serial.println (">>Error!");
}
delay(100);
}
Would appreciate some guidance.
Thanks, Puneet