This project is an Arduino-based multi-sensor control system that integrates a Light Dependent Resistor (LDR), ultrasonic distance sensor, buzzer, DC motor (via L293D driver), and a 16x2 LCD display. The system measures ambient light, distance to an object, and controls a motor and buzzer accordingly, displaying real-time data on the LCD.
- LDR Sensor: Measures ambient light and calculates the resistance of the photoresistor.
- Ultrasonic Sensor: Measures the distance to an object in centimeters.
- Buzzer: Emits a tone whose frequency is mapped to the light intensity.
- DC Motor Control: Motor speed is adjusted based on the measured distance.
- LCD Display: Shows resistance (with Ω symbol), buzzer frequency, distance, and motor speed (RPM).
- Arduino Uno (or compatible)
- LDR (Light Dependent Resistor)
- 10kΩ resistor (for LDR voltage divider)
- Ultrasonic sensor (HC-SR04 or similar)
- Buzzer
- L293D Motor Driver IC
- DC Motor
- 16x2 LCD Display (compatible with LiquidCrystal library)
- Jumper wires, breadboard, and power supply
| Component | Arduino Pin |
|---|---|
| LDR (Analog Out) | A0 |
| Buzzer | 8 |
| Ultrasonic Trig | 6 |
| Ultrasonic Echo | 7 |
| Motor IN1 | 9 |
| Motor IN2 | 10 |
| Motor Enable | 13 |
| LCD RS | 12 |
| LCD E | 11 |
| LCD D4 | 5 |
| LCD D5 | 4 |
| LCD D6 | 3 |
| LCD D7 | 2 |
Initialization:
The LCD displays "Initializing..." on startup.Sensor Readings:
- The LDR value is read and converted to resistance.
- The ultrasonic sensor measures distance to the nearest object.
Output Control:
- The buzzer emits a tone mapped to the light intensity.
- The DC motor speed is mapped to the measured distance (closer object = slower speed).
Display:
The LCD shows:- Top row: LDR resistance (Ω), buzzer frequency (Hz)
- Bottom row: Distance (cm), motor speed (RPM)
1000Ω=>1500HZ 20cm=>120RPM The main logic is implemented in [Arduino.ino]
- Reads LDR and calculates resistance.
- Reads distance from ultrasonic sensor.
- Maps sensor values to buzzer frequency and motor speed.
- Updates the LCD with real-time values.
Wiring:
Connect all components according to the pin mapping above.Upload Code:
Open [Arduino.ino] in the Arduino IDE and upload it to your Arduino board.Power Up:
Power the Arduino and observe the LCD and hardware responses.
You can view and simulate the circuit on TinkerCAD using the following link:
Open TinkerCAD Simulation
This repository also includes two 8051 assembly language programs that demonstrate microcontroller programming with the Atmel 8051 MCU:
An assembly implementation of a calculator that:
- Performs arithmetic operations (multiplication and division)
- Displays results on a 16x2 LCD display
- Features:
- Performs hex arithmetic operations on 8-bit values
- Displays input values and results on an LCD
- First line shows input values: "T:xxH U:xxH"
- Second line shows calculation results: "T:xxxxxx Q:xxxx"
- Includes comprehensive LCD control routines
- Handles hexadecimal to ASCII conversion for display
A countdown timer with alarm functionality:
- Uses Timer1 interrupts for accurate timing
- Displays countdown on a 4-digit 7-segment display
- Starts countdown from the value 9558
- Activates a buzzer/alarm (on P1.5) when the countdown reaches 0508
- Features:
- Display multiplexing for the 7-segment displays
- BCD countdown logic with carry handling
- Customized delay routines for display stability
- Interrupt-driven timing for accuracy
Both assembly programs demonstrate low-level hardware control, interrupt handling, and I/O operations on the Atmel 8051 microcontroller architecture.
For the 8051 assembly programs, you'll need:
- Atmel 8051 microcontroller (AT89C51/52 or compatible)
- For Calculator: 16x2 LCD display connected to Port 0 and Port 2
- For Timer: 4-digit 7-segment display (common cathode) connected to Port 0 and Port 2
- Buzzer connected to P1.5 (for the Timer program)
- 11.0592 MHz crystal oscillator
- 5V power supply
- Associated passive components (resistors, capacitors)
Arduino.ino: Main Arduino source code.Calculator.asm: Assembly code for a calculator (unrelated to Arduino sketch).Timer.asm: Assembly code for a timer (unrelated to Arduino sketch).