Created
March 7, 2019 21:25
-
-
Save glyons/dc579a840c09660e09ddecc75689a704 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "DigiKeyboard.h" | |
int led =1 ; | |
int sensorValue = 0; | |
int previousvalue=0; | |
void setup() { | |
// Just a example | |
} | |
void loop() { | |
sensorValue = analogRead(1) +1; //Read P2 | |
// Type out this string letter by letter on the computer (assumes US-style | |
// keyboard) | |
if (previousvalue!=sensorValue && sensorValue<=100) | |
{ | |
// this is generally not necessary but with some older systems it seems to | |
// prevent missing the first character after a delay: | |
DigiKeyboard.sendKeyStroke(0); | |
DigiKeyboard.println(sensorValue); | |
// It's better to use DigiKeyboard.delay() over the regular Arduino delay() | |
// if doing keyboard stuff because it keeps talking to the computer to make | |
// sure the computer knows the keyboard is alive and connected | |
previousvalue=sensorValue; | |
} | |
DigiKeyboard.delay(10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment