#include <LiquidCrystal.h>
// Define LED pins
#define LED_ESP32 2 // Assuming ESP32 code is also here
#define LED_UNO A3
#define LED_MEGA 13
// Initialize LCD with standard 4-bit interface pins connected to UNO
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
// Function to check if running on Arduino UNO (very basic, might not be foolproof)
bool isUno() {
// One simple way is to check if a UNO-specific pin is available.
// However, this is not a perfect method.
return true; // Assuming this code runs on the UNO for LCD
}
// Function to check if running on Arduino MEGA
bool isMega() {
// Similar to UNO, but MEGA has more analog pins.
return false; // Assuming this code doesn't handle MEGA LCD
}
void setup() {
Serial.begin(115200); // Start Serial Monitor
Serial.println("Setup Started...");
// Set LED pins as OUTPUT based on board
pinMode(LED_ESP32, OUTPUT); // Assuming ESP32 is handled here
if (isUno()) {
pinMode(LED_UNO, OUTPUT);
} else if (isMega()) {
pinMode(LED_MEGA, OUTPUT);
}
// Turn LEDs ON based on board
digitalWrite(LED_ESP32, HIGH);
if (isUno()) {
digitalWrite(LED_UNO, HIGH);
Serial.println("UNO LED turned ON.");
} else if (isMega()) {
digitalWrite(LED_MEGA, HIGH);
Serial.println("MEGA LED turned ON.");
}
// Initialize LCD only if running on UNO
if (isUno()) {
lcd.begin(20, 4);
lcd.setCursor(2, 0);
lcd.print("Group Assignment");
lcd.setCursor(4, 2);
lcd.print("4 lines, 20 cols");
Serial.println("LCD Initialized on UNO.");
}
}
void loop() {
Serial.println("Loop running...");
delay(1000); // Just to avoid too many prints
}