const int analogPin = A0; // Analog pin to read data
const int numReadings = 4; // Number of readings
int readings[numReadings]; // Array to store the readings
void setup() {
Serial.begin(9600); // Initialize serial communication
delay(1000); // Wait for the Serial Monitor to open
}
void loop() {
// Collect 4 readings and store in the array
for (int i = 0; i < numReadings; i++) {
readings[i] = analogRead(analogPin); // Read data from A0
delay(500); // Delay between readings
}
// Print the readings
Serial.println("Analog Readings:");
for (int i = 0; i < numReadings; i++) {
Serial.print("Reading ");
Serial.print(i + 1);
Serial.print(": ");
Serial.println(readings[i]);
}
delay(2000); // Wait before starting again
}