int joystickPinX = A1; // Analog input pin for the X axis of joystick
int ledPins[] = {6, 7, 8, 9, 10, 11, 12, 13}; // Pins for the 8 LEDs
int statusLedPin = 3; // Pin for the status LED
int temperatureThreshold = 45; // Threshold temperature in degrees Celsius
void setup() {
// Initialize the LED pins
for (int i = 0; i < 8; i++) {
pinMode(ledPins[i], OUTPUT);
}
pinMode(statusLedPin, OUTPUT);
}
void loop() {
// Read the X axis value of the joystick
int xValue = analogRead(joystickPinX);
// Map the X axis value to light up the corresponding LED
int ledIndex = map(xValue, 0, 1023, 0, 7);
for (int i = 0; i < 8; i++) {
if (ledIndex == i) {
digitalWrite(ledPins[i], HIGH);
} else {
digitalWrite(ledPins[i], LOW);
}
}
// Check temperature sensor and light up status LED if temperature exceeds threshold
float temperature = readTemperature(); // Function to read temperature sensor value
if (temperature >= temperatureThreshold) {
digitalWrite(statusLedPin, HIGH);
} else {
digitalWrite(statusLedPin, LOW);
}
delay(100); // Delay for smoother LED transitions
}
float readTemperature() {
// Function to read temperature sensor value
return 0; // Replace with actual reading from temperature sensor
}