Update pro_micro.ino
This commit is contained in:
+22
-14
@@ -25,28 +25,36 @@ Auch hilfreich:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int RXLED = 17; // The RX LED has a defined Arduino pin
|
#include "Keyboard.h"
|
||||||
// The TX LED was not so lucky, we'll need to use pre-defined
|
|
||||||
// macros (TXLED1, TXLED0) to control that.
|
const int RXLED = 17; // The RX LED has a defined Arduino pin
|
||||||
// (We could use the same macros for the RX LED too -- RXLED1,
|
const int buttonPin = 2;
|
||||||
// and RXLED0.)
|
int buttonState = 0;
|
||||||
|
int prevButtonState = HIGH;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
Serial.println("Hello Keyboard World");
|
||||||
pinMode(RXLED, OUTPUT); // Set RX LED as an output
|
pinMode(RXLED, OUTPUT); // Set RX LED as an output
|
||||||
// TX LED is set as an output behind the scenes
|
pinMode(buttonPin, INPUT_PULLUP);
|
||||||
|
digitalWrite(buttonPin, HIGH);
|
||||||
Serial.begin(9600); //This pipes to the serial monitor
|
Serial.begin(9600); //This pipes to the serial monitor
|
||||||
Serial1.begin(9600); //This is the UART, pipes to sensors attached to board
|
Keyboard.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
Serial.println("Hello world"); // Print "Hello World" to the Serial Monitor
|
buttonState = digitalRead(buttonPin);
|
||||||
Serial1.println("Hello!"); // Print "Hello!" over hardware UART
|
if ((buttonState != prevButtonState) && (buttonState == HIGH)) {
|
||||||
|
Serial.println("Now pressing button");
|
||||||
|
|
||||||
|
// Here starts the output action
|
||||||
|
//Keyboard.press(KEY_LEFT_GUI); // Command key in Mac, use KEY_LEFT_CTRL for Pc
|
||||||
|
Keyboard.press('v');
|
||||||
|
delay(100);
|
||||||
|
Keyboard.releaseAll(); // This is important after every Keyboard.press it will continue to be pressed
|
||||||
|
|
||||||
digitalWrite(RXLED, LOW); // set the LED on
|
digitalWrite(RXLED, LOW); // set the LED on
|
||||||
TXLED0; //TX LED is not tied to a normally controlled pin
|
delay(300);
|
||||||
delay(3000); // wait for a second
|
|
||||||
digitalWrite(RXLED, HIGH); // set the LED off
|
digitalWrite(RXLED, HIGH); // set the LED off
|
||||||
TXLED1;
|
}
|
||||||
delay(3000); // wait for a second
|
prevButtonState = buttonState;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user