Microbit and KY-034 7 color flashing LED
In this article, we connect a KY-034 7 color flashing LED to our Microbit – we will use Makecode and show the JaavScript and Python output as well
If the KY-034 7 color flashing LED module is supplied with voltage, a color sequence is automatically emitted by the LED. The LED has 7 different colors and thus also all resulting mixed colors.
Working voltage | 3V — 5V DC |
LED model | YB-3120B4PnYG-PM |
LED type | 5mm round head |
Parts Required
Name | Link | |
Microbit |
|
|
37 in one sensor kit | ||
Connecting cables |
Schematic/Connection
MICRO:BIT | SENSOR |
---|---|
Pin 0 | S |
GND | – |
Example
All of these are from the Microsoft Makecode site
MakeCode
Python
def on_button_pressed_a(): pins.digital_write_pin(DigitalPin.P0, 0) input.on_button_pressed(Button.A, on_button_pressed_a) def on_button_pressed_b(): pins.digital_write_pin(DigitalPin.P0, 1) input.on_button_pressed(Button.B, on_button_pressed_b)
JavaScript
input.onButtonPressed(Button.A, function () { pins.digitalWritePin(DigitalPin.P0, 0) }) input.onButtonPressed(Button.B, function () { pins.digitalWritePin(DigitalPin.P0, 1) })
Output
Press the A button then the B button on the microbit
Links