0% found this document useful (0 votes)
23 views3 pages

Arduino Project Hand Gesture Controller Product Layout

This Arduino sketch uses ultrasonic sensors to detect hand gestures and control media playback. It uses two sensors to separately detect the distance of the left and right hands. If both hands are detected within a close range, it will play or pause media. It can also lock control to each hand individually to detect gestures for adjusting volume or skipping tracks by moving the hand closer or further from the sensor. The sketch continuously measures the hand distances and controls media based on the detected gestures.

Uploaded by

Xenon Studio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

Arduino Project Hand Gesture Controller Product Layout

This Arduino sketch uses ultrasonic sensors to detect hand gestures and control media playback. It uses two sensors to separately detect the distance of the left and right hands. If both hands are detected within a close range, it will play or pause media. It can also lock control to each hand individually to detect gestures for adjusting volume or skipping tracks by moving the hand closer or further from the sensor. The sketch continuously measures the hand distances and controls media based on the detected gestures.

Uploaded by

Xenon Studio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Arduino Project Hand Gesture Controller

Product Layout
Arduino Sketch

const int trigger1 = 2; //Trigger pin of 1st Sesnor


const int echo1 = 3; //Echo pin of 1st Sesnor
const int trigger2 = 4; //Trigger pin of 2nd Sesnor
const int echo2 = 5;//Echo pin of 2nd Sesnor

long time_taken;
int dist,distL,distR;

void setup() {
Serial.begin(9600);

pinMode(trigger1, OUTPUT);
pinMode(echo1, INPUT);
pinMode(trigger2, OUTPUT);
pinMode(echo2, INPUT);
}

void calculate_distance(int trigger, int echo)


{
digitalWrite(trigger, LOW);
delayMicroseconds(2);
digitalWrite(trigger, HIGH);
delayMicroseconds(10);
digitalWrite(trigger, LOW);

time_taken = pulseIn(echo, HIGH);


dist= time_taken*0.034/2;
if (dist>50)
dist = 50;
}

void loop() { //infinite loopy


calculate_distance(trigger1,echo1);
distL =dist; //get distance of left sensor

calculate_distance(trigger2,echo2);
distR =dist; //get distance of right sensor

//Uncomment for debudding


/*Serial.print("L=");
Serial.println(distL);
Serial.print("R=");
Serial.println(distR);
*/

//Pause Modes -Hold


if ((distL >40 && distR>40) && (distL <50 && distR<50)) //Detect both hands
{Serial.println("Play/Pause"); delay (500);}

calculate_distance(trigger1,echo1);
distL =dist;

calculate_distance(trigger2,echo2);
distR =dist;
//Control Modes
//Lock Left - Control Mode
if (distL>=13 && distL<=17)
{
delay(100); //Hand Hold Time
calculate_distance(trigger1,echo1);
distL =dist;
if (distL>=13 && distL<=17)
{
Serial.println("Left Locked");
while(distL<=40)
{
calculate_distance(trigger1,echo1);
distL =dist;
if (distL<10) //Hand pushed in
{Serial.println ("Vup"); delay (300);}
if (distL>20) //Hand pulled out
{Serial.println ("Vdown"); delay (300);}
}
}
}

//Lock Right - Control Mode


if (distR>=13 && distR<=17)
{
delay(100); //Hand Hold Time
calculate_distance(trigger2,echo2);
distR =dist;
if (distR>=13 && distR<=17)
{
Serial.println("Right Locked");
while(distR<=40)
{
calculate_distance(trigger2,echo2);
distR =dist;
if (distR<10) //Right hand pushed in
{Serial.println ("Rewind"); delay (300);}
if (distR>20) //Right hand pulled out
{Serial.println ("Forward"); delay (300);}
}
}
}

delay(200);
}

*REMEMBER TO INSTAL PYTHON 1st AND OPEN THE PYTHON CONTROLLER APPLICATION IN YOUR
DESIRED DESKTOP

You might also like