Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
24 views

Interfacing RGB Led With Arduino

Uploaded by

b23cs1037
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Interfacing RGB Led With Arduino

Uploaded by

b23cs1037
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Interfacing RGB Led with Arduino

ER lab-10

Name: Mendpara Laksh Alpeshbhai


Roll No.: B23CS1037
Batch: B3

Aim:
1) To make a circuit using Arduino UNO that measures distance from an HC-SR04
ultrasonic sensor and glows blue light if the distance is less than 40 inch, glows
green light if distance is between 40 to 80 inch, and glows red light if the distance is
between 80 to 100 inch.
2) To make a circuit using Arduino UNO that measure distance from an HC-SR04
ultrasonic sensor and also store current and previous data in inch, thereafter will
glow yellow light if previous distance is lesser than current distance, else will glow
purple light.

Apparatus required: Arduino UNO, HC-SR04 ultrasonic sensor, common cathode RGB
light, four 220 ohm resistors.
Theory:

• In a common cathode RGB LED, the cathode of the internal LEDs are all connected to the
external cathode lead. To control each color, you need to apply a HIGH signal or VCC to the
red, green, and blue leads and connect the anode lead to the negative terminal of the power
supply.
• Pulse Width Modulation, or PWM, is a technique for getting analog results with digital
means. Digital control is used to create a square wave, a signal switched between on and
off. This on-off pattern can simulate voltages in between the full Vcc of the board (e.g., 5 V
on UNO, 3.3 V on a MKR board) and off (0 Volts) by changing the portion of the time the
signal spends on versus the time that the signal spends off. The duration of "on time" is
called the pulse width. To get varying analog values, you change, or modulate, that pulse
width. If you repeat this on-off pattern fast enough with an LED for example, the result is as
if the signal is a steady voltage between 0 and Vcc controlling the brightness of the LED. In
the graphic below, the green lines represent a regular time period. This duration or period is
the inverse of the PWM frequency. In other words, with Arduino's PWM frequency at about
500Hz, the green lines would measure 2 milliseconds each.

Experiment 1:
Make a circuit given below where cathode based RGB led light’s red, blue and grren light
terminal is connected to Arduino pin 5, 6, 7, respectively.
The code for given circuit is:

Observation:
For distance between 0-40inch For distance between 40-80inch For distance between 80-100inch

Conclusion: the experiment successfully demonstrated the creation of a distance-


measuring circuit using an Arduino UNO and HC-SR04 ultrasonic sensor. The circuit
accurately detected distances and illuminated LEDs to signify proximity levels. This
practical exercise not only enhanced understanding of Arduino programming and sensor
interfacing but also showcased the versatility and applicability of such systems in real-
world scenarios.

Experiment 2:
Make a circuit given below where cathode based RGB led light’s red, blue and grren light
terminal is connected to Arduino pin 5, 6, 7, respectively.

The code for given circuit is:


Observation:

If previous distance> current distance If current distance> previous distance

Conclusion: Our experiment successfully achieved the goal of creating a circuit using an
Arduino UNO and HC-SR04 ultrasonic sensor to measure distances and compare current
and previous data. The implementation resulted in a functional system capable of
accurately measuring distances and providing visual feedback through the illumination of
yellow and purple lights. This circuit showcases the practical application of Arduino-based
projects in real-world scenarios, with potential for further development and enhancement
in future iterations.

You might also like