Skip to main content

How to control RGB LED using Arduino Uno

RGB LED is the abbreviation of ‘’Red Green Blue Light Emitting Diode’’. RGB LED is the most amazing type of LED which has the ability to create millions of different shades of light colors using red, green, and blue colors.

Locker guard based on Arduino Uno




You can protect your locker using this simple locker guard system. This system generates a beep sound whenever someone attempts to open the locked safe. This system generates an alert sound when some light falls on it, in an open condition. If someone tries to open it then defiantly some light will fall inside the locker, that light will be detected by the Light-dependent resistor and the buzzer will generate an alert beep sound.
If the locker is closed then there will be no light that will fall on the light-dependent resistor hence buzzer will be off. you can understand the working of this project by watching the video mentioned below.



Circuit description

1.  Light-dependent resistor.............BUY




Light-dependent resistor works on the principle of photoconductivity. The light-dependent resistor is also known as photoresist or photocell. It is a kind of variable resistor whose resistance value varies with the light intensity falling on it. Therefore, light-dependent resistors are light-sensitive devices that are used to identify the presence and the absence of light in multiple applications. In this system Light-dependent resistor is used to notify the buzzer to make the sound when light falls on it.


2. Piezo  Buzzer..............................BUY





The piezo buzzer is a simple audio signaling device that is preferred to generate beep sound. Piezo buzzer consists of two legs one is longer (positive) and the other is a shorter leg (negative). The smaller leg is always connected to the ground and the longer leg is connected to the power supply. According to this system whenever the light-dependent resistor detects light falling on it only then buzzer get enough voltage to generate a beep sound. This sound will stop only when there is no light falling on the light-dependent resistor or when the locker is closed.

3. Liquid Crystal Display [LCD]............................BUY

Liquid crystal display (LCD) is the most popular device used in electronic projects to display important information on it regarding the project. LCD is a 16 pin interface device.





Pin description of the LCD:
  • VSS or GND: Preferred for the ground connection.
  • VCC or VDD: Used to connect +5 volt pin of the Arduino Uno board.
  • VEE or V0: Connected with the potentiometer to adjust the brightness of the LCD screen.
  • RS (Register Select): Used to select either instruction or data to be sent to the LCD screen.
  • RW (Read/Write): Used to select the mode either read or write.
  • E (Enable): Indicates to the LCD that data is ready to be written.
  • D0 to D7: Data pins.
  • A (Anode): +5 volt connected for the backlight of the LCD.
  • K (Cathode): The ground pin for the backlight of the LCD
4. Resistors:.......................BUY

I have used the 100-ohm resistor along with buzzer and 10 k ohm resistor along with Light-dependent resistor for better results.





5. Jumper Wires.................................BUY


Male to male jumper wires used to make the connection between all the components.




6. Circuit Schematic:

According to this project, we will connect pin numbers 2, 3, 4, and 5 of the Arduino board to data pin 4 to 7 of the LCD. The reset pin of the LCD will be connected to pin number 12 and the enable pin will be connected to pin number 11 of the Arduino board. RW (read/ write), K (cathode), and GND pin of the LCD will be connected to the GND pin. The buzzer will be connected along with the 100-ohm resistor to pin number 6. The light-dependent resistor will be connected with analog pin A0 along with a 10 k ohm resistor. Male to male jumper wires are used to make all the connections between devices. you can understand the whole circuit connectivity with the help below-mentioned fritzing circuit schematic. In the fritzing diagram, I have used a blue-colored wire connection to connect devices with Arduino Uno from the breadboard. The red-colored wire connections indicate the wired connectivity between LCD and Arduino Uno. The black-colored wires were used for the ground connections.




Source Code:

After connecting all the devices, the source code is uploaded via USB cable. I am providing the full source code. you can understand the whole code with the help of comments provided for each statement. 


#include<LiquidCrystal.h> // Include LCD header file.

LiquidCrystal G_LCD(12, 11, 5, 4, 3, 2); // Configure pins of LCD {LCD object name(RS, Enable, data pin-4, data pin-5, data pin-6, data pin-7).

const int G_LDR=A0; // Connect LDR to pin AO
const int G_BUZZER=6; // Connect buzzer to pin 6

void setup() 
{
  
Serial.begin(9600);
  
G_LCD.begin(16, 2); // Initallize the dimension of the display (width, height) 
G_LCD.clear(); // Clears the display

pinMode(G_LDR, INPUT); // Set LDR as input
pinMode(G_BUZZER, OUTPUT); // Set buzzer as output

}

void loop()
 {
  
G_LCD.setCursor(0,0); // Set the location of the displayed text to be written on LCD at colomn:0, row:0
G_LCD.print("Sensor value:"); // This statement prints on LCD screen
G_LCD.print(analogRead(G_LDR)); // Read data from LDR and print on LCD

int light_sensor=analogRead(G_LDR);// Store the value of LDR in light_sensor named integer variable.

delay(200);

G_LCD.setCursor(0,2);// Set the location of the displayed text to be written on LCD at colomn:0, row:2

if (light_sensor>=100) // If the value of LDR stored in light_sensor is greater than and equal to 100 
{
  
 G_LCD.setCursor(0,1); // Set the location of the displayed text to be written on LCD at colomn:0, row:1
  G_LCD.print("it's bright"); //Its bright 

tone(G_BUZZER, 1000);// Buzzer on with 1 KHz sound signal

delay(1000); // Delay for 1 sec
  
noTone(G_BUZZER);// Stop sound
  
G_LCD.clear(); // Clear the display
    
}
else
{
  
   G_LCD.setCursor(0,1); // Set the location of the displayed text to be written on LCD at colomn:0, row:1

  G_LCD.print("it's dark"); //Its dark
  
noTone(G_BUZZER); //Stop sound
    
}
}








                    

Comments

Post a Comment

Popular posts from this blog

Smart Plant Watering System Using ARDUINO UNO

As we all know, plants play an important role in our life, there are countless benefits we get from plants but the most important is fresh air and the pleasant atmosphere on the earth. Hence,   It is not only our social duty as well as the responsibility that we should plant trees as much as we can and also take care of them. But  the biggest challenge we face, is, taking care of them,

How to use LCD with Arduino Uno

Liquid crystal Display 16x2 (LCD) is a widely used electronic device to establish communication between the real world and the electronics-based machine world.

How to operate soil moisture sensor with Arduino

The soil moisture sensor is the most amazing sensor used to measure the quantity of water present in the soil and defines the moisture level of the soil as the output. Because of its amazing operating principle, this sensor is used in applications such as automatic irrigation systems, agriculture research applications, landscape irrigation, indoor planting system, and lawns. I have also made an advanced level project  "Smart Plant Watering System" using a soil moisture sensor.

ad

ad