Dancing Glove

The second assignment was to expand our initial analogue switch and make a program in Arduino that combines more digital inputs and outputs.

Since I kind of needed the shoes used in last week’s switch, I used the very same principle and applied it on a glove that somehow found a way to my suitcase after winter break.

I constructed one aluminium board which was connected to power, while middle finger was programmed as a switch to light the yellow LED up when connected, index finger made the same with the red LED and thumb was programmed to act as a legit switch that turns both LEDs on, or off.

//blinking
int ledYellow = 3;
int ledRed = 4;
int MiddleButtonPin = 2;
int MiddleButtonState = LOW;
int IndexButtonPin = 5;
int IndexButtonState = LOW;


//Thumb switch
int ThumbButtonPin = 6;
int ledYellowState = LOW;
int ledRedState = LOW;
int prevThumbButtonState = LOW;

void setup() {
  // put your setup code here, to run once:
  pinMode(ledYellow, OUTPUT);
  pinMode(ledRed, OUTPUT);
  pinMode(MiddleButtonPin, INPUT);
  pinMode(IndexButtonPin, INPUT);
  pinMode(ThumbButtonPin, INPUT);
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  
//THUMB BUTTON SWITCH ON AND OFF
  int currentThumbButtonState = digitalRead(ThumbButtonPin);
  if (currentThumbButtonState == HIGH && prevThumbButtonState == LOW) {
  if (ledYellowState == HIGH){
    ledYellowState = LOW;
  } else if (ledYellowState == LOW) {
    ledYellowState = HIGH;
  }
}
  if (currentThumbButtonState == HIGH && prevThumbButtonState == LOW) {
    if (ledRedState == HIGH){
      ledRedState = LOW;
    } else if (ledRedState == LOW) {
      ledRedState = HIGH;
    }
  }
digitalWrite(ledYellow, ledYellowState);
digitalWrite(ledRed, ledRedState);
prevThumbButtonState = currentThumbButtonState;


  //MIDDLEFINGER WITH YELLOW LIGHT INTERACTION

  MiddleButtonState = digitalRead(MiddleButtonPin);

  if (MiddleButtonState == HIGH) {
    digitalWrite(ledYellow, HIGH);
  } else {
    digitalWrite(ledYellow, LOW);
  }


  //INDEX FINGER WITH RED LIGHT INTERACTION

  IndexButtonState = digitalRead(IndexButtonPin);
  if (IndexButtonState == HIGH) {
    digitalWrite(ledRed, HIGH);
  } else {
    digitalWrite(ledRed, LOW);
  }

}

 

Leave a Reply