Controlling RGB led using Raspberry pi

Introduction

In this post we will see on controlling RGB LED using raspberry pi and python. RGB LED means red, blue and green LEDs. RGB LED products combine these three colors to produce over 16 million hues of light. 

Things you need

For this we will need following items:

  1. RGB LED
  2. 220 ohms resistor ( Note this is not required if you are using RGB module)
  3. Breadboard
  4. Raspberry PI Pico (You can use any other raspberry pi)
  5. Thorny IDE installed (refer my earlier post on Getting started with Raspberry Pi Pico)

Connection Diagram/Schematic

Breadboard connections

Code

The frequency (REDLed.freq) tells Raspberry Pi Pico how often to switch the power between on and off for the LED. The duty cycle(REDLed.duty_u16) tells the LED for how long it should be on each time. For Raspberry Pi Pico in MicroPython, this can range from 0 to 65535.

Summarizing

  • RGB LED is a combination of three LEDs in just one package: red, green and blue
  • You can generate different colors by adjusting the brightness of each of the three LEDs of the RGB LED
  • To adjust the brightness of each LED, you use a PWM signal.

For more info on raspberry pi PICO refer the official documentation from here.

Let me know how it goes for you. Controlling RGB led using Raspberry pi can be modified to work with also with Arduino and will post it some other time.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.