ASL to LED (AKA American Sign LED-uage)

For my project I wanted to combine American Sign Language and what we’ve been working on in class. So I decided to translate the sign language alphabet into Morse code (done through flashes on an LED). I used two flex sensors, one on my thumb and one on my forefinger to do so. For this project I only did the letters A through H because to go past that I would need another flex sensor as well as an accelerometer to accurately transmit the letters. However, for A through H only the thumb sensor would technically be needed, but for accuracy (and I bought the thing so I figured why not) I used the one on the forefinger as well. It took me a while to figure out exactly how to code it and I feel like there would be a way to shorten down the code, but I did not know how at this point. But the biggest time consumer was figuring out the sensor ranges needed to code. And here is the video explaining some of this and a demonstration.

//all the alphabet used to monitor my accuracy of handshapes
// to make sure it was picking up the right letter.
int A = 1;
int B = 2;
int C = 3;
int D = 4;
int E = 5;
int F = 6;
int G = 7;
int H = 8;
int dot = 500;
int dash = 1000;
int pause = 200;
void setup(){
  pinMode (8, OUTPUT);
  Serial.begin(9600);

}

void loop(){
  int input = analogRead(A1);
  int inputF = analogRead (A2);
  int flexFore = map (inputF, 320, 557, 0, 100);
  int flexNumbers = map(input, 360, 540, 0, 100);

  if (flexNumbers >= 90 && flexNumbers <=100){
    if (flexFore >= 25 && flexFore < 35){
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
      Serial.println(A);
    delay(3000);
    }
  }

   else if (flexNumbers >= 80 && flexNumbers <90){
     if (flexFore >=80 && flexFore <95) {
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
       Serial.println(H);
    delay(3000);
     }
  }
  else if (flexNumbers >=70 && flexNumbers <80) {
    if (flexFore >= 80 && flexFore <95){
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);  
    Serial.println(G);
    delay(3000);
    }
  }
  else if (flexNumbers >=60 && flexNumbers <70){
    if (flexFore >=50 && flexFore <60){
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);  
    Serial.println(C);
    delay(3000);
    }
  }
  else if (flexNumbers >=50 && flexNumbers <60) {
    if (flexFore >=30 && flexFore <40){
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
      Serial.println(F);
    delay(3000);
    }
  }
  else if (flexNumbers >=40 && flexNumbers <50) {
    if (flexFore >= 90 && flexFore <=100){
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
      Serial.println(D);
    delay(3000);
    }
  }
  else if (flexNumbers >=30 && flexNumbers <40){
    if (flexFore >=90 && flexFore <=100){
    digitalWrite (8, HIGH);
    delay (dash);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
    delay (pause);
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
      Serial.println(B);
    delay(3000);
    }
  }
  else if (flexNumbers <30){
    if (flexFore >= 0 && flexFore < 20){
    digitalWrite (8, HIGH);
    delay (dot);
    digitalWrite (8, LOW);
      Serial.println(E);
    delay(3000);
    }
  }

}

 

Leave a Reply