Code: Select all
#include <sys/time.h>
timeval *past_time;
timeval *current_time;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
gettimeofday(past_time, NULL);
}
void loop() {
// put your main code here, to run repeatedly:
gettimeofday(current_time, NULL);
if((current_time->tv_usec - past_time->tv_usec) > 2000)
{
Serial.println(analogRead(32));
gettimeofday(past_time, NULL);
}
}