Arduino LED Control
Arduino LED Control
Materials Needed
Arduino board (e.g., Arduino Uno)
USB cable to connect Arduino to a computer
Breadboard
Jumper wires
Potentiometer (used to simulate the light sensor)
Theory
I2C (Inter-Integrated Circuit) is a synchronous serial communication protocol commonly used to
connect low-speed peripherals to microcontrollers and microprocessors. It requires only two wires
for communication: SDA (Serial Data Line) and SCL (Serial Clock Line).
Circuit Diagram
We will simulate the I2C light sensor using a potentiometer connected to an analog pin on the
Arduino. This setup will help us mimic the behavior of a light sensor by varying the potentiometer
to simulate different light intensities.
Connections
1. Potentiometer:
Connect the middle pin of the potentiometer to Analog Pin A0 on the Arduino.
Connect one of the side pins to the 5V pin on the Arduino.
Connect the other side pin to the GND pin on the Arduino.
Implementation Steps
1. Build the circuit on a breadboard as per the circuit diagram.
2. Connect the Arduino to your computer using a USB cable.
3. Write and upload the Arduino sketch to read the simulated light sensor data
(potentiometer) and send it over the serial port.
Arduino Sketch
2. Loop Function:
int sensorValue = analogRead(A0);: Reads the analog value from the potentiometer
connected to pin A0.
float voltage = sensorValue * (5.0 / 1023.0);: Converts the analog value (0-1023) to a
voltage (0-5V).
float lux = voltage * 200;: Converts the voltage to a light intensity value in lux. This
conversion factor is an example and should be adjusted based on the actual sensor's
characteristics.
Serial.print("Light Intensity (Lux): "); and Serial.println(lux);: Prints the light
intensity readings to the serial monitor.
delay(1000);: Waits for a second before taking the next reading.
Conclusion
By completing this lab, you have learned how to simulate an I2C light sensor using a potentiometer
and an Arduino. You have gained experience in reading analog values, converting them to
meaningful units, and sending the data over the serial port for display on a computer. This
knowledge is essential for various applications, including environmental monitoring, smart lighting
systems, and IoT (Internet of Things) projects.
This lab provides hands-on experience with sensor interfacing and serial communication,
reinforcing fundamental concepts in digital communication and sensor data processing.