1234567891011121314151617 |
- void setup() {
- // $ stty -F /dev/ttyUSB0 | grep speed
- Serial.begin(115200);
- }
- void loop() {
- // effective sample rate measured in epy_block_0.py
- delayMicroseconds(800);
- // > 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
- // 16 bits/sample / 115200 Baud * 1e6 μs/sec = 139 μs/sample
- Serial.write(reading >> 8);
- Serial.write(reading & 0xff);
- }
|