#include <Arduino.h>
// Define the number of LEDs
const int numLEDs = 3;
// Define the GPIO pins to which the LEDs are connected
int ledPins[numLEDs] = {25, 26, 27};
// Threshold values for each LED (assuming input range is 0 to 100)
int thresholds[numLEDs] = {33, 66, 100};
// Define the input values to simulate
int inputValues[] = {10, 40, 70, 100, 50}; // Example predefined input values
int inputIndex = 0; // Index to iterate through the input values
int numInputs = sizeof(inputValues) / sizeof(inputValues[0]);
void setup() {
// Set LED pins as OUTPUT
for (int i = 0; i < numLEDs; i++) {
pinMode(ledPins[i], OUTPUT);
}
// Initialize serial communication
Serial.begin(115200);
Serial.println("Predefined input values will be used to update the LED bar graph.");
}
void updateLEDBarGraph(int value) {
// Iterate through each LED and update its state
for (int i = 0; i < numLEDs; i++) {
if (value <= thresholds[i]) {
// Turn on the LED
digitalWrite(ledPins[i], HIGH);
} else {
digitalWrite(ledPins[i], LOW);
// Turn off the LED
}
}
}
void loop() {
// Use the predefined input values to update the LED bar graph
int inputValue = inputValues[inputIndex];
updateLEDBarGraph(inputValue);
Serial.println("Input Value: " + String(inputValue));
// Move to the next input value
inputIndex = (inputIndex + 1) % numInputs;
// Wait for a while before updating the LEDs again
delay(1000); // Adjust the delay as needed
}