Electronics Projects

LCD connections

LCD pin Connection

VSS (1) GND

VDD (2) 5V

VO (3) Middle pin of 10kΞ© potentiometer

RS (4) Arduino 12

RW (5) GND

E (6) Arduino 11

D0–D3 (7–10) Not connected

D4 (11) Arduino 5

D5 (12) Arduino 4

D6 (13) Arduino 3

D7 (14) Arduino 6

LED+ (15) 5V, with suitable resistor if required

LEDβˆ’ (16) GND

πŸ’» Arduino code for LCD

#include <LiquidCrystal.h>

// LCD: RS, E, D4, D5, D6, D7

LiquidCrystal lcd(12, 11, 5, 4, 3, 6);

const int switchPin = 2;

const int greenLED = 8;

const int redLED = 9;

const int buzzer = 10;

void setup() {

pinMode(switchPin, INPUT);

pinMode(greenLED, OUTPUT);

pinMode(redLED, OUTPUT);

pinMode(buzzer, OUTPUT);

lcd.begin(16, 2);

lcd.setCursor(0, 0);

lcd.print("SECURITY SYSTEM");

lcd.setCursor(0, 1);

lcd.print("Starting...");

delay(2000);

lcd.clear();

}

void loop() {

int switchState = digitalRead(switchPin);

if (switchState == HIGH) {

digitalWrite(greenLED, HIGH);

digitalWrite(redLED, LOW);

lcd.setCursor(0, 0);

lcd.print("SYSTEM: ON ");

lcd.setCursor(0, 1);

lcd.print("ALARM: ACTIVE ");

tone(buzzer, 1000);

delay(300);

noTone(buzzer);

delay(700);

} else {

digitalWrite(greenLED, LOW);

digitalWrite(redLED, HIGH);

noTone(buzzer);

lcd.setCursor(0, 0);

lcd.print("SYSTEM: OFF ");

lcd.setCursor(0, 1);

lcd.print("ALARM: DISABLED ");

}

}

🧰 Components

Arduino Uno Γ—1

Breadboard Γ—1

Slide switch Γ—1

Green LED Γ—1

Red LED Γ—1

220Ξ© resistors Γ—2

Piezo buzzer Γ—1

Jumper wires

πŸ’» Arduino code

int switchPin = 2;

int greenLED = 8;

int redLED = 9;

int buzzer = 10;

void setup() {

pinMode(switchPin, INPUT);

pinMode(greenLED, OUTPUT);

pinMode(redLED, OUTPUT);

pinMode(buzzer, OUTPUT);

Serial.begin(9600);

}

void loop() {

int switchState = digitalRead(switchPin);

if (switchState == HIGH) {

// Security system ON

digitalWrite(greenLED, HIGH);

digitalWrite(redLED, LOW);

// Buzzer beeps

tone(buzzer, 1000);

delay(300);

noTone(buzzer);

delay(700);

} else {

// Security system OFF

digitalWrite(greenLED, LOW);

digitalWrite(redLED, HIGH);

noTone(buzzer);

}

}

🚨 Tinkercad Project: Mini Security Control System

🎯 Project idea

The slide switch acts as an ON/OFF security switch.

πŸ”΄ Switch OFF β†’ Red LED OFF, buzzer OFF

🟒 Switch ON β†’ Green LED ON and buzzer sounds

Learners can later modify it so the buzzer only sounds when an alarm condition occurs.

πŸ”Œ Exact connections

Slide switch

One outer pin β†’ 5V

Middle pin β†’ Arduino Pin 2

Other outer pin β†’ GND

Green LED

Long leg β†’ 220Ξ© resistor β†’ Pin 8

Short leg β†’ GND

Red LED

Long leg β†’ 220Ξ© resistor β†’ Pin 9

Short leg β†’ GND

Buzzer

Positive (+) β†’ Pin 10

Negative (βˆ’) β†’ GND

Note: You Should not have a separate Adruino have one extra breadboard for connecting the lcd only

🚦 Project: Automatic Traffic Light

Building a traffic light system simulator

Connections

Resistor

πŸ”΄ Red

pin 13

220Ξ©

🟑 Yellow

pin 12

220Ξ©

🟒 Green

pin 11

220Ξ©

🧰 Components

Arduino Uno

3 LEDs: Red, Yellow, Green

3 Γ— 220Ξ© resistors

Breadboard

Jumper wires

int red = 13;

int yellow = 12;

int green = 11;

void setup() {

pinMode(red, OUTPUT);

pinMode(yellow, OUTPUT);

pinMode(green, OUTPUT);

}

void loop() {

// Green light

digitalWrite(green, HIGH);

digitalWrite(yellow, LOW);

digitalWrite(red, LOW);

delay(5000);

// Yellow light

digitalWrite(green, LOW);

digitalWrite(yellow, HIGH);

delay(2000);

// Red light

digitalWrite(yellow, LOW);

digitalWrite(red, HIGH);

delay(5000);

}

How it works

🟒 Green turns on for 5 seconds.

🟑 Yellow turns on for 2 seconds.

πŸ”΄ Red turns on for 5 seconds.

The cycle repeats automatically.