If this 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.

Technical data

Voltage range 3.3 V - 5 V

Pin assignment

Code example Arduino

Connection assignment Arduino

Arduino Sensor
Pin 13 Signal
- -
Ground GND

This code example shows how an LED can be switched on for four seconds and then switched off for two seconds by means of a definable output spin.

int Led  =  13;
 
void setup  ( )
{
  pinMode (Led, OUTPUT)  ;  // Initialization  Output spin for the LED
}
 
void loop  ( )  //Main program loop
{
  digitalWrite   (Led, HIGH)  ;  // LED  is switched on
  delay (4000)  ;  // Wait mode for 4 seconds
  digitalWrite  (Led, LOW) ;  // LED  is switched off
  delay (2000)  ;  // Wait mode for another two seconds in which the LED is switched off
}

Sample program download

KY034-Arduino-ON-OFF.zip

Code example Raspberry Pi

Connection assignment Raspberry Pi

Raspberry Pi Sensor
GPIO 24 [Pin 18] Signal
- -
Ground [ Pin 6 ] GND
#  Required modules are imported and set up
import RPi. GPIO  as  GPIO
import time
  
GPIO.setmode (GPIO.BCM) 
  
# The input pin to which the sensor is connected is declared here.  In addition the PullUP resistor at the input is activated
LED_PIN = 24
GPIO.setup(LED_PIN, GPIO.OUT, initial= GPIO.LOW)
  
print ("LED test [press CTRL+C to end the test]")
 
# Main program loop
try:
    while True:
        print("LED 4 seconds on")
        GPIO.output(LED_PIN,GPIO.HIGH) # LED is switched on
        time.sleep(4)  # Wait mode for 4 seconds
        print("LED 2 seconds off") 
        GPIO.output (LED_PIN,GPIO.LOW) # LED is switched off
        time.sleep (2)   # Standby mode for another two seconds when the LED is switched off
 
# Tidying up after the program is finished
except KeyboardInterrupt:
    GPIO.cleanup ()

Sample program download

KY034-RPi-ON-OFF.zip

To start with the command:

sudo python3 KY034-RPi.py

Code example Micro:Bit

Connection assignment Micro:Bit:

Micro:Bit Sensor
Pin 1 Signal
- +V
Ground GND

Sample program download

microbit-KY-034.zip