Added some button handling to Digispark_Passkey and cleanups
This commit is contained in:
parent
1e1459fa50
commit
fae5de0bed
2 changed files with 43 additions and 10 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
// the setup routine runs once when you press reset:
|
// the setup routine runs once when you press reset:
|
||||||
void setup() {
|
void setup() {
|
||||||
// initialize the digital pin as an output.
|
// initialize the digital pin as an output.
|
||||||
|
|
@ -10,8 +9,8 @@ void setup() {
|
||||||
void loop() {
|
void loop() {
|
||||||
digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage level)
|
digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||||
digitalWrite(1, HIGH);
|
digitalWrite(1, HIGH);
|
||||||
delay(100); // wait for a second
|
delay(1000); // wait for a second
|
||||||
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
|
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
|
||||||
digitalWrite(1, LOW);
|
digitalWrite(1, LOW);
|
||||||
delay(100); // wait for a second
|
delay(1000); // wait for a second
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,52 @@
|
||||||
#include "DigiKeyboard.h"
|
#include "DigiKeyboard.h"
|
||||||
#include <ezButton.h>
|
#include <ezButton.h>
|
||||||
|
|
||||||
|
int ACTION_PIN = 0;
|
||||||
|
int LED_PIN = 1;
|
||||||
|
|
||||||
|
ezButton button(ACTION_PIN);
|
||||||
|
|
||||||
|
char *passwords[] = {
|
||||||
|
"0qMpI7Af06Z4XnMDhzXROnEgtuxPsCPLiBJT90Rb1F2BZKCmIhpLOdxtBpurUa9Tg",
|
||||||
|
"1qMpI7Af06Z4XnMDhzXROnEgtuxPsCPLiBJT90Rb1F2BZKCmIhpLOdxtBpurUa9Tg",
|
||||||
|
"2qMpI7Af06Z4XnMDhzXROnEgtuxPsCPLiBJT90Rb1F2BZKCmIhpLOdxtBpurUa9Tg",
|
||||||
|
"3qMpI7Af06Z4XnMDhzXROnEgtuxPsCPLiBJT90Rb1F2BZKCmIhpLOdxtBpurUa9Tg"
|
||||||
|
};
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
pinMode(0, INPUT);
|
pinMode(LED_PIN, OUTPUT);
|
||||||
pinMode(1, OUTPUT);
|
digitalWrite(LED_PIN, LOW);
|
||||||
DigiKeyboard.delay(3000);
|
delay(500);
|
||||||
|
digitalWrite(LED_PIN, HIGH);
|
||||||
|
//pinMode(ACTION_PIN, INPUT);
|
||||||
|
button.setCountMode(COUNT_RISING);
|
||||||
|
button.setDebounceTime(0);
|
||||||
|
DigiKeyboard.delay(0);
|
||||||
DigiKeyboard.sendKeyStroke(0);
|
DigiKeyboard.sendKeyStroke(0);
|
||||||
DigiKeyboard.println("qMpI7Af06Z4XnMDhzXROnEgtuxPsCPLiBJT90Rb1F2BZKCmIhpLOdxtBpurUa9Tg");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
digitalWrite(1, HIGH);
|
button.loop();
|
||||||
|
|
||||||
|
/*digitalWrite(LED_PIN, HIGH);
|
||||||
delay(25);
|
delay(25);
|
||||||
digitalWrite(1, LOW);
|
digitalWrite(1, LOW);
|
||||||
delay(10000);
|
delay(10000);*/
|
||||||
//DigiKeyboard.delay(500000);
|
|
||||||
|
if(button.isPressed()) {
|
||||||
|
//DigiKeyboard.println("Hello World!");
|
||||||
|
/*DigiKeyboard.println(passwords[0]);
|
||||||
|
DigiKeyboard.println(passwords[1]);
|
||||||
|
DigiKeyboard.println(passwords[2]);
|
||||||
|
DigiKeyboard.println(passwords[3]);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long count = button.getCount();
|
||||||
|
|
||||||
|
// press button five times to get a password
|
||||||
|
if(count == 5) {
|
||||||
|
//DigiKeyboard.println(count);
|
||||||
|
DigiKeyboard.println(passwords[0]);
|
||||||
|
button.resetCount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue