Close

Glove 8- Final Code

A project log for Wearable Computer Rig & Powerglove Mouse

Inspired by Martin Magnusson's wearable computer, I've refined the display, and modified a Nintendo Powerglove to be the complete interface!

Scott SScott S 06/14/2015 at 21:150 Comments

My final code is linked below.

https://github.com/slicer364/powerglove-mouse/blob/master/HACKADAY_POWERGLOVE

A few notes,

Since the last code post, we add the "ledbutton" on/off switch code, and put the rest of the code together.

//led button on/off code is below:
const int buttonPin = 11;    // the number of the pushbutton pin
const int ledPin = 12;      // the number of the LED pin
int ledbuttonledState = HIGH;         // the current state of the output pin
int ledbuttonbuttonState;             // the current reading from the input pin
int ledbuttonlastButtonState = LOW;   // the previous reading from the input pin
long ledbuttonlastDebounceTime = 0;  // the last time the output pin was toggled
long ledbuttondebounceDelay = 50;    // the debounce time; increase if the output flickers


void loop() {

  //LED button code (temporary on/off switch)  

   int ledbuttonreading = digitalRead(buttonPin); 
    if (ledbuttonreading != ledbuttonlastButtonState) {
     ledbuttonlastDebounceTime = millis();

  } 

    if ((millis() - ledbuttonlastDebounceTime) > ledbuttondebounceDelay) {    
       if (ledbuttonreading != ledbuttonbuttonState) {
      ledbuttonbuttonState = ledbuttonreading;  
           if (ledbuttonbuttonState == HIGH) {
        ledbuttonledState = !ledbuttonledState;//if button is pressed, swap the led state
      }
    }
  }
  digitalWrite(ledPin, ledbuttonledState);   
 ledbuttonlastButtonState = ledbuttonreading;

    if (ledbuttonledState == HIGH) {
 /*ledbutton has to be lit in order to allow mouse clicks, mouse movement and precision mode to toggle. 
*/
    if (fingbool2 == 0) {
         Mouse.press(MOUSE_LEFT);   
      }
      else  {
       Mouse.release(MOUSE_LEFT);
      }
   }
    }
  } 
Next, I'll go into how I made the heads up display and "computer box" !

Discussions