// Microvolt serial streamer: prints one line per sample, comma-separated, for the Web Serial plotter. // Works on an Arduino Uno/Nano (10-bit ADC) or an ESP32 (12-bit). Adjust the pins and rate below. // // Wiring for Phase 1 project B ("One channel of you"): amplifier output -> A0, amplifier mid-supply reference -> A1. // The plotter subtracts nothing for you; print what you want to see. const int PIN_SIGNAL = A0; const int PIN_REF = A1; // optional second channel; comment out below if unused const unsigned long SAMPLE_US = 4000; // 4000 us = 250 samples per second unsigned long nextSample = 0; void setup() { Serial.begin(115200); analogReference(DEFAULT); // Uno/Nano: 5 V full scale. For 1.1 V full scale use INTERNAL. nextSample = micros(); } void loop() { unsigned long now = micros(); if ((long)(now - nextSample) >= 0) { nextSample += SAMPLE_US; // fixed-interval scheduling, immune to how long Serial.print takes int sig = analogRead(PIN_SIGNAL); int ref = analogRead(PIN_REF); Serial.print(sig); Serial.print(','); Serial.println(ref); } }