RGB LED
An RGB LED is an LED that lets you independently control its red, green and blue elements.
Parts
RGB LED
4 jumper wires
3 10k resistors
Wire the circuit
An RGB LED has 4 pins. The longest pin (#3 on the LED) is the "cathode" pin that should be wired to ground. The other pins are as follows:
Pin #1: Green
Pin #2: Blue
Pin #3: Cathode/Gnd
Pin #4: Red
You will need to put resistors between the RGB LED pins and the wires that connect to the GPIO pins. The specific resistor you'll need varies depending on the type of RGB LED and its power requirements. 10k resistors seemed to work fine with the RGB LED used in this example.
This chart shows the RGB LED pin to GPIO pin mappings:
Create the Xojo app
You'll use the open-source Xojo GPIO library to control the RGB LED. This code will randomly change the color of the LED:
GPIO.SetupGPIO
' These are the pins to which you wired the RGB LED
Const kRedPin = 21
Const kBluePin = 20
Const kGreenPin = 16
Var led As New GPIO.RGBLED(kRedPin, kGreenPin, kBluePin)
' Display random colors
For i As Integer = 1 To 100
led.SetColor(System.Random.InRange(0, 255), _
System.Random.InRange(0, 255), _
System.Random.InRange(0, 255))
App.DoEvents(100)
Next
' turn everything off
led.Off
Build the app for Linux ARM and transfer it to the Raspberry Pi to run it.