void setup()
{
Serial.begin( 115200 );
}
void loop()
{
const uint8_t number_of_readings = 10;
const uint32_t interval1 = 100;
const uint32_t interval2 = 200;
const uint32_t timestamp = millis();
static uint32_t timer_timestamp = timestamp;
static uint32_t timer_interval = 0;
if ( timestamp - timer_timestamp >= timer_interval )
{
timer_timestamp = timestamp;
static bool toggle = false;
static uint32_t readings_sum = 0;
readings_sum += analogRead( A0 );
static uint8_t readings_counter = 0;
if ( ++readings_counter == number_of_readings )
{
readings_counter = 0;
toggle = false;
const uint32_t readings_average = readings_sum / number_of_readings;
Serial.print( "readings_average = " );
Serial.println( readings_average );
readings_sum = 0;
}
toggle = !toggle;
timer_interval = ( toggle == true ) ? interval1 : interval2;
}
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
pot1:GND
pot1:SIG
pot1:VCC