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
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.