Microbit and KY-009 RGB LED

In this article, we connect a KY-029 Dual Color LED to our Microbit – we will use Makecode and show the JavaScript and Python output as well

The KY-009 RGB Full Color LED module emits a range of colors by mixing red, green, and blue light.

This module consists of a 5050 SMD LED and a 4 pin header.

Operating Voltage 5V max
Red 1.8V ~2.4V
Green 2.8V ~ 3.6V
Blue 2.8V ~ 3.6V
Forward Current 20mA ~ 30mA
Operating Temperature -25°C to 85°C [-13°F ~ 185°F]
Board Diemsions 18.5mm x 15mm [0.728in x 0.591in]

Depending on the input voltage, series resistors are recommended.

Series resistor (3.3 V) [Red] 180 Ω
Series resistor (3,3 V) [Green] 100 Ω
Series resistor (3,3 V) [Blue] 100 Ω

Parts Required

Name Link
Microbit
37 in one sensor kit
Connecting cables

 

Schematic/Connection

MICRO:BIT SENSOR
Pin 1 R
Pin 2 G
Pin 0 B
GND GND

Example

All of these are from the Microsoft Makecode site – this example just cycles through red, green and blue

MakeCode

Python

def on_forever():
    pins.digital_write_pin(DigitalPin.P0, 1)
    pins.digital_write_pin(DigitalPin.P1, 0)
    pins.digital_write_pin(DigitalPin.P2, 0)
    basic.pause(1000)
    pins.digital_write_pin(DigitalPin.P0, 0)
    pins.digital_write_pin(DigitalPin.P1, 1)
    pins.digital_write_pin(DigitalPin.P2, 0)
    basic.pause(1000)
    pins.digital_write_pin(DigitalPin.P0, 0)
    pins.digital_write_pin(DigitalPin.P1, 0)
    pins.digital_write_pin(DigitalPin.P2, 1)
    basic.pause(1000)
basic.forever(on_forever)

 

JavaScript

basic.forever(function on_forever() {
    pins.digitalWritePin(DigitalPin.P0, 1)
    pins.digitalWritePin(DigitalPin.P1, 0)
    pins.digitalWritePin(DigitalPin.P2, 0)
    basic.pause(1000)
    pins.digitalWritePin(DigitalPin.P0, 0)
    pins.digitalWritePin(DigitalPin.P1, 1)
    pins.digitalWritePin(DigitalPin.P2, 0)
    basic.pause(1000)
    pins.digitalWritePin(DigitalPin.P0, 0)
    pins.digitalWritePin(DigitalPin.P1, 0)
    pins.digitalWritePin(DigitalPin.P2, 1)
    basic.pause(1000)
})

 

Leave a Comment

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :