diff --git a/nano_c_mk1/nano_c_mk1.ino b/nano_c_mk1/nano_c_mk1.ino new file mode 100644 index 0000000..31555c8 --- /dev/null +++ b/nano_c_mk1/nano_c_mk1.ino @@ -0,0 +1,32 @@ +#include + +#define WAIT_TIME 1000UL // default wait time each value read +#define ADS_MAX 4 // # of analog input pins of an ADS1115 +#define VOLTAGE_RANGE 6.144f // ADS1115 default gain (+/- 6.144V) +#define CONST_I2C 32768 // a constant value + +unsigned long currTime; // non-blocking timer +Adafruit_ADS1115 adc; +int i; // loop iterators + +void setup() { + Wire.begin(); + Serial.begin(19200); + adc.begin(); + currTime = millis(); +} + +void loop() { + // TODO: The current reading is too slow for even the arduino's own ide's grapher cannot parse the data in time + if (millis() - currTime >= WAIT_TIME) { // non-blocking time delay + Serial.print("["); + for (i = 0; i < ADS_MAX; i++) { + Serial.print(adc.readADC_SingleEnded(i) * VOLTAGE_RANGE / CONST_I2C); // a raw to voltage conversion based from the library's method + if (i != ADS_MAX - 1) { + Serial.print(", "); + } + } + Serial.println("]"); + currTime = millis(); + } +} \ No newline at end of file