Program Help: Triggering Voltage average

Hello

I am using a seeed XIAO and an ADS1115 to read in voltages and I want to toggle on/off a voltage average. I attached my code.
When I run it it just spams out a single read and the toggles on pins 10 an 9 don’t seem to work like I want. I am trying to start the event with Pin10&9 High, Pause when Pin 10 is High and Pin 9 is Low, and reset the values When Pin 10 is low.

Any ideas what I am doing wrong?

//Libraries
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1115 ads;

//Digital Pins used
const int triggerPin = 10;
const int eventPin = 9;

//Variables
unsigned long int a1=0; unsigned long int a2=0; unsigned int counter=0;
float avg1=0; float avg2=0; 

void setup() {
   //Start Serial Communitcation
   Serial.begin(9600);
   Serial.println("Starting");
   //Setup Trigger Input and Event Trigger
   pinMode(triggerPin,INPUT);
   pinMode(eventPin,INPUT);
  
  //Start ADC
   ads.begin();
   delay(1000);
}

void loop() {
  //Event Trigger
if (digitalRead(eventPin) == HIGH);{
  
  //Start polling
  if (digitalRead(triggerPin) == HIGH);{
    a1=a1 + ads.readADC_Differential_0_1();
    a2=a2 + ads.readADC_Differential_2_3();
    counter++;
    }
  if (digitalRead(triggerPin) == LOW);{
    //average collected values
    avg1 = (a1/counter)*(5.0000/65535);
    avg2 = (a2/counter)*(5.0000/65535);
    //print values to computer
    Serial.print(counter);Serial.print(", ");Serial.print(avg1,4);Serial.print(", ");Serial.println(avg2,4);
    }
delay(1);
}
if (digitalRead(eventPin) == LOW);{
   //Reset all colltector values and counter to 0
    a1 = 0;
    a2 = 0;
    counter = 0;
    delay(digitalRead(eventPin) == HIGH);
    Serial.print(counter);Serial.print(", ");Serial.print(avg1);Serial.print(", ");Serial.println(avg2);
    delay(1);
  }
delay(1);
}

Voltage_Average.ino (951 Bytes)

You have semicolons at the end of all of your if statements, rendering the conditionals ineffective.

Thanks that fixed my issue

hairem:
Thanks that fixed my issue

Awesome!