Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int buttonPin = 2;
- int previousButtonState = HIGH;
- void setup() {
- pinMode(buttonPin, INPUT);
- Keyboard.begin();
- }
- void loop() {
- int buttonState = digitalRead(buttonPin);
- if ((buttonState != previousButtonState)
- && (buttonState == HIGH)) {
- Keyboard.press('z');
- delay(80);
- Keyboard.release('z');
- }
- else{
- if ((buttonState != previousButtonState)
- && (buttonState == LOW)) {
- Keyboard.release('z');
- }
- previousButtonState = buttonState;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment