Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glyons/dc579a840c09660e09ddecc75689a704 to your computer and use it in GitHub Desktop.
Save glyons/dc579a840c09660e09ddecc75689a704 to your computer and use it in GitHub Desktop.
#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