Difference between revisions of "KY-034 7 Colour LED flash-module"

From SensorKit X40 Wiki

Jump to: navigation, search
(Created page with "==Picture== none ==Technical data / Short description== If you connect this module with a power supply, a LED will light up which changes its colour auto...")
 
(No summary)
Line 1: Line 1:
 
==Picture==
 
==Picture==
[[Datei:ky-034.jpg|none]]
+
[[File:ky-034.jpg|358x358px|none]]
  
 
==Technical data / Short description==
 
==Technical data / Short description==
Line 8: Line 8:
  
 
==Pinout==
 
==Pinout==
[[Datei:3_G_NC_S.png|none]]
+
[[File:3_G_NC_S.png|none]]
  
 
==Code example Arduino==
 
==Code example Arduino==

Revision as of 16:28, 6 March 2017

Picture

ky-034.jpg

Technical data / Short description

If you connect this module with a power supply, a LED will light up which changes its colour automatically. It includes 7 different colours.

Voltage range: 3,3V - 5V

Pinout

3 G NC S.png

Code example Arduino

This code example shows how you can switch a LED on for 4 seconds and than off for 2 seconds via defined output pin.

int Led = 13;

void setup ()
{
  pinMode (Led, OUTPUT); // Initialization of the LED output pin
}

void loop () // main program loop
{
  digitalWrite (Led, HIGH); // LED will be switched on
  delay (4000); // waitmode for 4 seconds
  digitalWrite (Led, LOW); // LED will be switched off
  delay (2000); // waitmode for another 2 seconds
}

Connections Arduino:

Sensor Signal = [Pin 13]
Sensor [N.C] =
Sensor GND = [Pin GND]

Example program download:

LedTestArduino_4On_2Off.zip

Code example Raspberry Pi

Example in the language python

# Needed modules will be imported and configured
import RPi.GPIO as GPIO
import time
 
GPIO.setmode(GPIO.BCM)
 
# Declaration of the input pin which is connected with the sensor.
# Additional to that the pull up resistor from the input will be activated.
LED_PIN = 24
GPIO.setup(LED_PIN, GPIO.OUT, initial= GPIO.LOW)
 
print "LED-Test [press ctrl+c to end]"

# main program loop
try:
        while True:
                print("LED is on for 4 seconds")
                GPIO.output(LED_PIN,GPIO.HIGH) #LED will be switched on
                time.sleep(4) # Waitmode for 4 seconds
                print("LED is off for 2 Sekunden") 
                GPIO.output(LED_PIN,GPIO.LOW) #LED will be switched off
                time.sleep(2) # Waitmode for another 2 seconds
 
# Scavenging work after the end of the program
except KeyboardInterrupt:
        GPIO.cleanup()


Connections Raspberry Pi:

Sensor Signal = GPIO24 [Pin 18]
Sensor [N.C] =
Sensor GND = GND [Pin 6]

Example program download

LedTest_RPi_4On_2Off.zip

To start with the command:

sudo python LedTest_RPi_4On_2Off.py