2021-01-29 06:31:58 -05:00
|
|
|
//
|
|
|
|
// FILE: asyncAnalogTest.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// VERSION: 0.1.1
|
|
|
|
// DATE: 2018-09-05
|
|
|
|
|
2021-10-19 05:14:50 -04:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
#include "AsyncAnalog.h"
|
|
|
|
|
2021-10-19 05:14:50 -04:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
AsyncAnalog AA(A0);
|
|
|
|
|
|
|
|
uint32_t start = 0;
|
|
|
|
uint32_t duration = 0;
|
|
|
|
uint16_t count = 0;
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println("start: ");
|
|
|
|
Serial.println(analogRead(0));
|
|
|
|
|
|
|
|
AA.start();
|
|
|
|
start = micros();
|
|
|
|
}
|
|
|
|
|
2021-10-19 05:14:50 -04:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
|
|
|
|
// if sample ready
|
|
|
|
if (AA.ready())
|
|
|
|
{
|
|
|
|
// process sample
|
|
|
|
duration = micros() - start;
|
|
|
|
|
|
|
|
Serial.print(duration);
|
|
|
|
Serial.print("\t");
|
|
|
|
Serial.print(AA.value());
|
|
|
|
Serial.print("\t");
|
|
|
|
Serial.print(count);
|
|
|
|
Serial.println();
|
|
|
|
|
|
|
|
// request a new sample
|
|
|
|
AA.start();
|
|
|
|
start = micros();
|
|
|
|
count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// do other stuff here
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
2021-10-19 05:14:50 -04:00
|
|
|
|
|
|
|
// -- END OF FILE --
|