// Define the pins for the LED lights and light intensity modulator const int LED_PIN = 9; const int MODULATOR_PIN = 10; // Define the pins for the screen and keyboard #include LiquidCrystal lcd(12, 11, 5, 4, 3, 2); const int ROWS = 2; const int COLS = 3; char keys[ROWS][COLS] = { {'1', '2', '3'}, {'4', '5', '6'} }; byte rowPins[ROWS] = {A3, A2}; byte colPins[COLS] = {A1, A0, 13}; Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS); void setup() { // Set the LED and modulator pins as outputs pinMode(LED_PIN, OUTPUT); pinMode(MODULATOR_PIN, OUTPUT); // Set up the screen and display a welcome message lcd.begin(16, 2); lcd.print("Car LED Lights"); lcd.setCursor(0, 1); lcd.print("Press a key..."); // Set up the keyboard keypad.setDebounceTime(50); } void loop() { // Read the value from the keyboard char key = keypad.getKey(); // If a key is pressed, process it if (key != NO_KEY) { // Clear the screen and display the selected key lcd.clear(); lcd.print("Key: "); lcd.print(key); // Set the LED lights and modulator based on the selected key switch (key) { case '1': analogWrite(MODULATOR_PIN, 0); analogWrite(LED_PIN, 0); break; case '2': analogWrite(MODULATOR_PIN, 63); analogWrite(LED_PIN, 63); break; case '3': analogWrite(MODULATOR_PIN, 127); analogWrite(LED_PIN, 127); break; case '4': analogWrite(MODULATOR_PIN, 191); analogWrite(LED_PIN, 191); break; case '5': analogWrite(MODULATOR_PIN, 255); analogWrite(LED_PIN, 255); break; case '6': analogWrite(MODULATOR_PIN, 0); analogWrite(LED_PIN, 255); break; default: break; } // Display the properties on the screen lcd.setCursor(0, 0); lcd.print("Intensity: "); lcd.print(analogRead(MODULATOR_PIN)); lcd.print(" "); lcd.setCursor(0, 1); lcd.print("Brightness: "); lcd.print(analogRead(LED_PIN)); lcd.print(" "); } }