123456789101112131415161718192021222324252627 |
- #include "version.h"
- // https://www.arduino.cc/reference/en/language/functions/time/micros/
- const unsigned long SAMPLE_INTERVAL_MICROSECONDS = 1000000L;
- void setup() {
- // $ stty -F /dev/ttyUSB0 | grep speed
- Serial.begin(115200);
- // Serial.println("https://git.hammerle.me/fphammerle/TODO");
- // Serial.println(PROJECT_VERSION);
- }
- unsigned long last_sample_micros = 0;
- void loop() {
- while (micros() - last_sample_micros < SAMPLE_INTERVAL_MICROSECONDS) {
- delay(1);
- }
- // > On ATmega based boards [...], it takes about 100 microseconds (0.0001
- // s) to read an analog input, [...]
- // https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/
- unsigned short reading = analogRead(A0);
- // $ tail --follow /dev/ttyUSB0 | od --format=u2 --endian=big --width=2
- Serial.write(reading >> 8);
- Serial.write(reading & 0xff);
- last_sample_micros = micros();
- }
|