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

Arduino UNO Controlled I2C LCD Display and Relay Switching System

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled I2C LCD Display and Relay Switching System

Circuit Documentation

Summary of the Circuit

This circuit is designed to interface an Arduino UNO with an I2C LCD screen, a toggle switch, a 4-channel relay module, and a temperature sensor (LM35). The Arduino UNO serves as the central processing unit, controlling the relay states based on the input from the toggle switch and displaying messages on the LCD screen. The relay module allows for controlling high-power devices, while the temperature sensor provides environmental feedback. The circuit is powered by a 5V DC source, and a resistor is included to provide current limiting or voltage division as required.

Component List

Arduino UNO

Toggle Switch

I2C LCD 16x2 Screen

Resistor

DC Source 5V

Relay 4 Channel 5v

Temperature Sensor (LM35)

Wiring Details

Arduino UNO

Toggle Switch

I2C LCD 16x2 Screen

Resistor

DC Source 5V

Relay 4 Channel 5v

Temperature Sensor (LM35)

Documented Code

/*
 * Arduino UNO Interface with I2C LCD
 * This code initializes the I2C LCD and displays a message.
 * It also reads the state of a toggle switch and controls a relay based on the switch state.
 */

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

// Initialize the LCD with I2C address 0x27 and 16x2 display
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Pin definitions
const int toggleSwitchPin = 2;
const int relayPin1 = 9;
const int relayPin2 = 10;
const int relayPin3 = 11;
const int relayPin4 = 12;

void setup() {
  // Initialize the LCD
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Hello, World!");

  // Initialize the toggle switch pin
  pinMode(toggleSwitchPin, INPUT);

  // Initialize relay pins
  pinMode(relayPin1, OUTPUT);
  pinMode(relayPin2, OUTPUT);
  pinMode(relayPin3, OUTPUT);
  pinMode(relayPin4, OUTPUT);

  // Set all relays to off
  digitalWrite(relayPin1, LOW);
  digitalWrite(relayPin2, LOW);
  digitalWrite(relayPin3, LOW);
  digitalWrite(relayPin4, LOW);
}

void loop() {
  // Read the state of the toggle switch
  int switchState = digitalRead(toggleSwitchPin);

  // Control the relay based on the switch state
  if (switchState == HIGH) {
    digitalWrite(relayPin1, HIGH);
  } else {
    digitalWrite(relayPin1, LOW);
  }

  // Add more logic here if needed
}

This code is designed to run on the Arduino UNO and controls the relay module based on the state of the toggle switch. It also initializes the I2C LCD and displays a greeting message. The code is structured with setup and loop functions, typical of Arduino sketches.