GY-63_MS5611/libraries/AsyncAnalog/examples/asyncAnalogTest/asyncAnalogTest.ino

64 lines
940 B
Arduino
Raw Normal View History

2021-01-29 06:31:58 -05:00
//
// FILE: asyncAnalogTest.ino
// AUTHOR: Rob Tillaart
2024-04-06 14:00:19 -04:00
// PURPOSE: demo
2021-01-29 06:31:58 -05:00
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;
2021-12-13 13:46:42 -05:00
2021-01-29 06:31:58 -05:00
void setup()
{
Serial.begin(115200);
2024-04-06 14:00:19 -04:00
Serial.println(__FILE__);
Serial.print("ASYNCANALOG_LIB_VERSION: ");
Serial.println(ASYNCANALOG_LIB_VERSION);
Serial.print("\nstart: ");
2021-01-29 06:31:58 -05:00
Serial.println(analogRead(0));
2024-04-06 14:00:19 -04:00
// request initial measurement
2021-01-29 06:31:58 -05:00
AA.start();
start = micros();
}
2021-10-19 05:14:50 -04:00
2021-01-29 06:31:58 -05:00
void loop()
{
2024-04-06 14:00:19 -04:00
// if measurement ready
2021-01-29 06:31:58 -05:00
if (AA.ready())
{
2024-04-06 14:00:19 -04:00
// get data
2021-01-29 06:31:58 -05:00
duration = micros() - start;
2024-04-06 14:00:19 -04:00
uint16_t val = AA.value();
2021-01-29 06:31:58 -05:00
2024-04-06 14:00:19 -04:00
// process measurement
2021-01-29 06:31:58 -05:00
Serial.print(duration);
2024-04-06 14:00:19 -04:00
Serial.print('\t');
Serial.print(val);
Serial.print('\t');
Serial.println(count);
2021-01-29 06:31:58 -05:00
2024-04-06 14:00:19 -04:00
// request a new measurement
2021-01-29 06:31:58 -05:00
AA.start();
start = micros();
2024-04-06 14:00:19 -04:00
2021-01-29 06:31:58 -05:00
count = 0;
}
2024-04-06 14:00:19 -04:00
// do other stuff here
2021-01-29 06:31:58 -05:00
count++;
}
2021-10-19 05:14:50 -04:00
2024-04-06 14:00:19 -04:00
// -- END OF FILE --