Code for Operation
Code for Operation
h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
mySerial.begin(9600);
delay(15000);
}
void loop() {
// put your main code here, to run repeatedly:
int x = analogRead(xpin);
delay(50);
int y = analogRead(ypin);
delay(50);
int z = analogRead(zpin);
delay(50);
int thumb;
int pointer;
int middle;
int nomx;
int nomy;
int nomz;
thumb = analogRead(flex1);
pointer = analogRead(flex2);
middle = analogRead(flex3);
nomx = x-265;
nomy = y-253;
nomz = z-323;
Serial.print(thumb);
Serial.print("\ ");
Serial.print(pointer);
Serial.print("\ ");
Serial.print(middle);
Serial.print("\ ");
Serial.print(nomx);
Serial.print("\ ");
Serial.print(nomy);
Serial.print("\ ");
Serial.print(nomz);
Serial.print("\
");
Serial.println("");
delay(500);
//group1
if ((thumb > 175) && (thumb < 210) && (pointer > 210) && (pointer < 235) &&
(nomy > 75) && (nomy < 95)) {
mySerial.print("LOOK FORWARD");
}
else if ((thumb > 175) && (thumb < 200) && (pointer > 210) && (pointer < 235)
&& (nomy > 160) && (nomy < 175)) {
mySerial.print("LOOK DOWN");
}
else if ((thumb > 175) && (thumb < 200) && (pointer > 210) && (pointer <
230)&& (nomy > 20) && (nomy < 35)) {
mySerial.print("LOOK UP");
}
//group2
else if ((thumb > 160) && (thumb < 195) &&(pointer > 160) && (pointer < 200)
&& (nomy > 28) && (nomy < 43)) {
mySerial.print("OKAY");
}
else if ((thumb > 190) && (thumb < 210) && (pointer > 180) && (pointer < 200)
&& (nomy > 160) && (nomy < 180)) {
mySerial.print("HOLD");
}
else if ((thumb > 160) && (thumb < 200) &&(pointer > 160) && (pointer < 190)
&& (nomy > 60) && (nomy < 75)) {
mySerial.print("PRONTO");
}
//group3
else if ((thumb > 230) && (thumb < 250) && (pointer > 150) && (pointer < 180)
&& (nomy >80) && (nomy < 100)) {
mySerial.print("CALL ME");
}
else if ((thumb > 230) && (thumb < 250) && (pointer > 150) && (pointer < 180)
&& (nomy >105) && (nomy < 125)) {
mySerial.print("THUMBS DOWN");
}
else if ((thumb > 230) && (thumb < 250) && (pointer > 150) && (pointer < 189)
&& (nomy >58) && (nomy < 70)) {
mySerial.print("I LOVE YOU");
}
else if ((thumb > 230) && (thumb < 250) && (pointer > 220) && (pointer < 235)
&& (nomy > 80) && (nomy < 105)) {
mySerial.print("GIVE ME");
}
else if ((thumb > 175) && (thumb < 195) && (pointer > 170) && (pointer < 190)
&& (nomy > 90) && (nomy < 110)) {
mySerial.print("GIVE ME SOME");
}
else{
mySerial.print("...");
}
}