Last active
May 27, 2023 18:29
-
-
Save bmidgley/616460a99ecb038555ccf6f0ee2d6bc5 to your computer and use it in GitHub Desktop.
attiny85 code to print to usb keyboard the analog value at adc1 (p2); also outputs 1 on the GPIO p1 when below 300 (and lighting the LED)
This file contains hidden or 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" | |
#define ADC1_P2 1 | |
void setup() { | |
pinMode(1, OUTPUT); | |
} | |
void loop() { | |
char output[32]; | |
int analog; | |
DigiKeyboard.sendKeyStroke(0); | |
analog = analogRead(ADC1_P2); | |
digitalWrite(1, analog < 300 ? HIGH : LOW); | |
snprintf(output, sizeof(output), "%d\n", analog); | |
DigiKeyboard.println(output); | |
DigiKeyboard.delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment