When construction the virtual world demo we will use two different types of sensors
There are quite a few different types of breakout boards implementing RGB LEDs on the market which have to connected to the controller in different ways. Most of them just consist of 3 LEDs of the base colors implemented in a single package. Some of the breakout boards however have the necessary current limiting resistors already on board while for others they must be provided externally.
There is also a type of "intelligent" LED where the RGB values are provided in a serial data stream.
KY-009 SMD LED needing external resistors |
Lily Pad Tri-Color LED |
Standard 3 color LED with resistors on board |
WS2812 "intelligent" LED |
It is an excellent introductory exercise to try programming the LEDs and we will go about it in steps. First the device must be connected to the Raspberry Pi controller which is done through the cobbler and the bread board. Depending on the breakout board used we will need additional external 330 Ohm resistors on each of the color components (KY-009). Then we connect as follows:
Making a LED light up is one of the most simple programming exercises possible and therefore ideally suited to get us going with Python programming.
The following programs work for common cathode LEDs (KY-009 and Standard 3 color LED) only for which the GND pin is common. For Common Anode LEDs, which have a common Vcc like the the Lily Pad one you must pull the individual red, green, blue pins low to make the LED light up.
![]() |
![]() |
Three programs will be developed with increasing difficulty:
I | Attachment | History | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|---|
![]() |
2018-01-30-182614_520x384_scrot.png | r1 | manage | 143.8 K | 2018-01-30 - 17:27 | UliRaich | |
![]() |
commonAnode.png | r1 | manage | 23.7 K | 2018-03-06 - 13:30 | UliRaich | |
![]() |
commonCathode.png | r1 | manage | 23.7 K | 2018-03-06 - 13:30 | UliRaich | |
![]() |
fullColors.py.txt | r1 | manage | 0.7 K | 2018-01-30 - 19:24 | UliRaich | |
![]() |
ky-009.png | r1 | manage | 145.5 K | 2018-01-30 - 17:15 | UliRaich | |
![]() |
lilyPadTriColorLED.png | r1 | manage | 152.5 K | 2018-01-30 - 17:15 | UliRaich | |
![]() |
rgbColorIntensities.py.txt | r1 | manage | 1.0 K | 2018-01-30 - 19:24 | UliRaich | |
![]() |
rgbLED-1.png | r1 | manage | 128.6 K | 2018-01-30 - 17:15 | UliRaich | |
![]() |
rgbLED.py.txt | r1 | manage | 0.6 K | 2018-01-30 - 19:24 | UliRaich | |
![]() |
rgbLED.tar.gz | r1 | manage | 0.7 K | 2018-01-30 - 19:26 | UliRaich |