ENTREGABLE 6
Iteración 1 (Hardware - Software - Manufactura Digital). Diagrama de Flujo
Iteración 1 (Hardware - Software - Manufactura Digital). Diagrama de Flujo
#include <Keyboard.h>
const int switchPin = 3;
const unsigned long debounceDelay = 50;
const unsigned long multiPressDelay = 500;
int switchState = HIGH;
int lastSwitchState = HIGH;
unsigned long lastDebounceTime = 0;
unsigned long lastKeyPressTime = 0;
int pressCount = 0;
bool shouldType = true;
void setup() {
pinMode(switchPin, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
int reading = digitalRead(switchPin);
if (reading != lastSwitchState) {
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
if (reading != switchState) {
switchState = reading;
if (switchState == LOW) {
if ((millis() - lastKeyPressTime) < multiPressDelay) {
pressCount++;
} else {
pressCount = 1;
shouldType = true;
}
lastKeyPressTime = millis();
if (pressCount == 3 && shouldType) {
Keyboard.release('v'); // Liberar la tecla 'v' si se ha presionado dos veces antes
Keyboard.release('g'); // Liberar la tecla 'g' si se ha presionado una vez antes
Keyboard.write('y');
shouldType = false;
} else if (pressCount == 2 && shouldType) {
Keyboard.release('g'); // Liberar la tecla 'g' si se ha presionado una vez antes
Keyboard.write('v');
} else if (pressCount == 1 && shouldType) {
Keyboard.write('g');
}
}
}
}
lastSwitchState = reading;
}