code
code
h>
// Pin definitions
// Duration constants
void setup() {
pinMode(greenLedPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
pinMode(blueLedPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
resetIndicators();
void loop() {
waitForVoltage(analogInput1, checkVoltageA0);
blueLedOn("Press SW1");
waitForVoltage(analogInput2, checkVoltageA1);
// Step 3: Press SW2
blueLedOn("Press SW2");
waitForVoltage(analogInput3, checkVoltageA2);
resetIndicators();
totalBoardsMeasured++;
// Display the current board number and total boards measured on the LCD
lcd.clear();
lcd.print("Board: ");
updateCounts();
displayResults();
cycleCount++;
// Wait for detachment of A0, A1, A2 before starting the next cycle
waitForDetachment();
updateLCDStatus();
void resetIndicators() {
digitalWrite(greenLedPin, LOW);
digitalWrite(redLedPin, LOW);
digitalWrite(blueLedPin, LOW);
digitalWrite(blueLedPin, HIGH);
lcd.clear();
lcd.print(message);
Serial.println(message);
String checkingMessage;
if (analogPin == analogInput1) {
lcd.clear();
lcd.print(checkingMessage);
Serial.println(checkingMessage);
while (true) {
if ((analogPin == analogInput1 && voltage >= 1.0 && voltage <= 3.0) ||
lcd.clear();
lcd.print("Checking...");
Serial.println(voltage);
delay(300);
Serial.println(newVoltage);
delay(buzzerOkDuration);
} else {
digitalWrite(redLedPin, HIGH);
delay(buzzerErrorDuration);
} else {
digitalWrite(redLedPin, HIGH);
delay(buzzerErrorDuration);
delay(ledDuration);
resetIndicators();
digitalWrite(greenLedPin, HIGH);
delay(buzzerOkDuration);
} else {
digitalWrite(redLedPin, HIGH);
delay(buzzerErrorDuration);
delay(ledDuration);
resetIndicators();
digitalWrite(greenLedPin, HIGH);
delay(buzzerOkDuration);
} else {
digitalWrite(redLedPin, HIGH);
delay(buzzerErrorDuration);
}
delay(ledDuration);
resetIndicators();
void updateCounts() {
if (allChecksOk) {
countA0Ok++;
} else {
countA0Error++;
void displayResults() {
void updateLCDStatus() {
void waitForDetachment() {
while (true) {
if (voltageA0 < 0.1 && voltageA1 > 4.0 && voltageA2 > 4.0) {
lcd.clear();