connect@howdiyworld.com
|

RGB LED

BLOCK DIAGRAM

Procedure

  1. What is an RGB LED Works?
  2. Connection
  3. Program
  4. RGB LED Control

How an RGB LED Works?

A RGB LED or Light Emitting Diode is a Semiconductor  with Four terminal(Pin) component, the Four terminals are R,G,B(+)Positive and (-)Negative. To get Red Light Connect R and Negative pins where R is positive, To get Green and Blue do the same to G and B Pins.

Connecting the LED-Strip

·    Connect the Red(R) Pin to the 29th pin on the breadboard Via Jumpers

·    Connect the Green(G) Pin to 31st pin on the breadboard Via Jumpers

·    Connect the Blue(B) Pin to 33rd pin in the bread board Via Jumpers and

·    Connect the Ground(GND) pin to 39th.

Connecting the Raspberry Pi

import RPi.GPIO as GPIO # GPIO pin access Header file Lib
import time # time dependent Lib
GPIO.setwarnings(False) # all the GPIO pin and intial warnings false
GPIO.setmode(GPIO.BOARD) # Here select the mode BOARD or BCM
GPIO.setup(29,GPIO.OUT) # pin set up input or output (GPIO.IN or GPIO.OUT)
GPIO.setup(31,GPIO.OUT)
GPIO.setup(33,GPIO.OUT)
GPIO.output(29,False) #intially LOW all pins here False means LOW
GPIO.output(31,False)
GPIO.output(33,False)
def get_input(n): #Get the input
a=n #store any variable
if a=="RED": # Check the variable is RED
GPIO.output(29,True) # if it is red 29 pin is HIGH (True means HIGH)
print(“RED ON")
time.sleep(1) #one second time delay
GPIO.output(29,False) #then 29th pin is LOW(False)
time.sleep(1)
if a=="GREEN": # check the variable is GREEN
GPIO.output(31,True) # if it is red 31 pin is HIGH (True means HIGH)
print(“GREEN ON")
time.sleep(1) #one second time delay
GPIO.output(31,False) #then 31 pin is LOW(False)
time.sleep(1)
if a=="BLUE": # check the variable is BLUE
GPIO.output(33,True) # if it is red 33 pin is HIGH (True means HIGH)
print(“BLUE ON")
time.sleep(0.5) #one second time delay
GPIO.output(33,False) #then 33 pin is LOW(False)
time.sleep(0.5)

Connecting the power jack

Here if you press RED Button the LED will Emit Red Light, if you press Green Button the LED will Emit Green Light, if you press Blue Button the LED will Emit Blue Light.

Social media & sharing icons powered by UltimatelySocial
Facebook
Twitter
YouTube
LinkedIn
Instagram