Electronics

LED 7-Color Automatic Flashing Module KY-034

AED 5.25

1

Description

7 color flashing LED module uses an automatic 5mm round high-brightness light-emitting diode, and it changes its color every 2-3 seconds automatically and includes 7 colors in total. Therefore the module has only 2 pins for the signal and the ground. The operation voltage is between 3.3V and 5V, so no resistor is needed.


In the following Arduino Code, we turn on the LED 7-Color Automatic Flashing Module KY-034 for 20 seconds and then start the sketch all over again.

 7 color flash module has 3 pins, VCC, Ground, and 3rd pin is not connected. There are two ways to power on the 7 color flash module. You can connect VCC directly to +5v of Arduino or Connect VCC to any of the available digital pins. Connecting to digital pins gives freedom to use the module when required in the program. For this, connect VCC to digital pin 11.



void setup () {
// Initialize the digital pin as an output.
// Pin 11 has an LED connected on most Arduino boards:
pinMode (11, OUTPUT);
}
void loop () {
digitalWrite (11, HIGH); // set the LED on
delay (20000); // wait for a second
digitalWrite (11, LOW); // set the LED off
delay (20000); // wait for a second
}



Connect the 7 Color LED Flash module KY-034 in Raspberry Pi with code:


7 color flash module has 3 pins as we mentioned up, VCC, Ground, and 3rd pin are not connected. There are two ways to power on the 7 color flash module. You can connect VCC directly to +5v of Raspberry Pi or Connect VCC to any of the available GPIO pins. Connecting to GPIO pins gives the freedom to use the module when required in the program. For this, connect VCC to GPIO pin 17.

This is code for interfacing 7 color LED Flash module KY-034 in Raspberry Pi. First import GPIO and Time Library. Set the GPIO 17 as an output pin. In a while loop, GPIO is set to high, delay for a second, set the pin to low, and delay for a second.


import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.OUT)
while True:
GPIO.out(17, GPIO.HIGH)
time.sleep(1)
GPIO.out(17, GPIO.LOW)
time.sleep(1)