Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO LED Control System with LCD Display and Pushbutton Interface

View and Edit Project In Cirkit DesignerImage of Arduino UNO LED Control System with LCD Display and Pushbutton Interface

Circuit Documentation

Summary

This circuit is designed to control an array of LEDs and an LCD screen using an Arduino UNO. The user can select different modes using pushbuttons. Modes include random LED blinking at different speeds and all LEDs blinking simultaneously. The selected mode is displayed on the LCD screen.

Component List

Resistors

LEDs

Microcontrollers

Pushbuttons

Wiring Details

Resistors

LEDs

Microcontrollers

Pushbuttons

Code Documentation

Arduino UNO Code

// This Arduino sketch controls an array of LEDs and an LCD screen. The user can
// select different modes using pushbuttons. Modes include random LED blinking
// at different speeds and all LEDs blinking simultaneously. The selected mode
// is displayed on the LCD screen.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Initialize the I2C LCD (address: 0x27, columns: 16, rows: 2)
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Define LED and switch pins
const int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10};
const int numLeds = 9;
const int switchPins[] = {A0, A1, A2, A3};

// Variables for timing
int delayTime = 500; // Default delay for blinking
unsigned long mode4StartTime = 0;
bool mode4Active = false;

// Setup function
void setup() {
  // Initialize LCD
  lcd.init();
  lcd.backlight();

  // Set LED pins as output
  for (int i = 0; i < numLeds; i++) {
    pinMode(ledPins[i], OUTPUT);
    digitalWrite(ledPins[i], LOW);
  }

  // Set switch pins as input
  for (int i = 0; i < 4; i++) {
    pinMode(switchPins[i], INPUT_PULLUP);
  }

  // Display initial message
  lcd.setCursor(0, 0);
  lcd.print("Select a Mode");
}

// Random LED blinking function
void randomBlink(int delayTime) {
  int randomLed = random(0, numLeds);
  digitalWrite(ledPins[randomLed], HIGH);
  delay(delayTime);
  digitalWrite(ledPins[randomLed], LOW);
  delay(delayTime);
}

// All LEDs on/off function
void allLedsOnOff(int duration) {
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(ledPins[i], HIGH);
  }
  delay(duration);
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(ledPins[i], LOW);
  }
  delay(duration);
}

// Loop function
void loop() {
  // Check for mode switches
  if (digitalRead(switchPins[0]) == LOW) {
    // Mode 1: Random LED blink
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Mode 1: Random");
    delayTime = 500; // Default speed
    mode4Active = false; // Exit mode 4
  } else if (digitalRead(switchPins[1]) == LOW) {
    // Mode 2: Slow random blink
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Mode 2: Slow");
    delayTime = 100