- Arduino
- Raspberry Pi
- Raspberry Pi Pico
- Micro:Bit
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 |
GND |
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
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 Raspberry Pi
Connection assignment Raspberry Pi
Raspberry Pi |
Sensor |
GPIO 24 [Pin 18] |
Signal |
GND [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
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 Raspberry Pi Pico
Pin assignment Raspberry Pi Pico
Raspberry Pi Pico |
Sensor |
GPIO18 |
Signal |
- |
- |
GND |
GND |
This code example shows how an LED can be alternately switched on for ten seconds and then switched off for two seconds by means of a definable output pin.
# Load libraries
from machine import Pin
import time
# Initialization of GPIO18 as output
led = Pin(18, Pin.OUT)
# Endless loop for the ON/OFF switching of the LED
while True:
led.value(0)
time.sleep(2)
led.value(1)
time.sleep(10)
Example program download
KY034-Pico-ON-OFF.zip