Simply use an RGB LED with an ARDUINO UNO board

Marc DANIEL

Well-Known Member
Licensed User
An RGB LED is essentially made up of three LEDs—red, green, and blue—captured within a single transparent or diffuse epoxy lens. Each internal LED chip emits light at a specific wavelength corresponding to its color: red typically around 620–630 nm, green around 520–530 nm, and blue around 460–470 nm. These chips are carefully positioned next to each other to ensure their light blends smoothly, allowing the human eye to perceive a combined color rather than three separate colors. This compact integration enables RGB LEDs to produce millions of hues through variable intensity control of the three channels.

RGB_LED.jpg


Structurally, an RGB LED package includes four wires or pins extending from the base. Three of these pins correspond to the color channels: R (red), G (green), and B (blue), while the fourth serves as a common terminal shared between the three LEDs. The common terminal can be connected to either the positive supply voltage or ground, depending on the type of RGB LED.

RGB LED Connection.jpg


RGB_LED.B4R:
'LGB_LED - Diode à couleurs changeantes
' With Arduino UNO Board

#Region Project Attributes
    #AutoFlushLogs: True
    #CheckArrayBounds: True
    #StackBufferSize: 300
#End Region


Sub Process_Globals
    Public Serial1 As Serial
    Private RedLED, GreenLED, BlueLED As Pin
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("Start")
    RedLED.Initialize(11, RedLED.MODE_OUTPUT)
    GreenLED.Initialize(10, GreenLED.MODE_OUTPUT)
    BlueLED.Initialize(9,BlueLED.MODE_OUTPUT)
    Start
End Sub

Sub Start
    For i = 1 To 3
        
        ' Red Color (full red, no green, no blue)
        RedLED.AnalogWrite(255)
        GreenLED.AnalogWrite(0)
        BlueLED.AnalogWrite(0)
        Delay(2000)
    
        ' Green Color (no red, full green, no blue)
        RedLED.AnalogWrite(0)
        GreenLED.AnalogWrite(255)
        BlueLED.AnalogWrite(0)
        Delay(2000)
    
        ' Blue Color (no red, no green, full blue)
        RedLED.AnalogWrite(0)
        GreenLED.AnalogWrite(0)
        BlueLED.AnalogWrite(255)
        Delay(2000)   
        
        ' Cyan
        RedLED.AnalogWrite(0)
        GreenLED.AnalogWrite(255)
        BlueLED.AnalogWrite(255)
        Delay(2000)
        
        ' Yellow
        RedLED.AnalogWrite(255)
        GreenLED.AnalogWrite(255)
        BlueLED.AnalogWrite(0)
        Delay(2000)
        
        ' Violet
        RedLED.AnalogWrite(128)
        GreenLED.AnalogWrite(0)
        BlueLED.AnalogWrite(128)
        Delay(2000)
    Next
    
    RedLED.DigitalWrite(False)
    GreenLED.DigitalWrite(False)
    BlueLED.DigitalWrite(False)
End Sub
 

Attachments

  • RGB_LED.zip
    995 bytes · Views: 23

Marc DANIEL

Well-Known Member
Licensed User
VIDEO

RGB color chart

  • Here are some examples of common colors with their RGB codes:
  • Red: (255, 0, 0)
  • Green: (0, 255, 0)
  • Blue: (0, 0, 255)
  • Yellow: (255, 255, 0)
  • Cyan: (0, 255, 255)
  • Magenta: (255, 0, 255)
  • White: (255, 255, 255)
  • Black: (0, 0, 0)
Couleurs.jpg
 
Last edited:
Top