3-colour LED module (HCMODU0057)

LCD, TFT, OLED, LED modules
Post Reply
admin
Site Admin
Posts: 727
Joined: Sun Aug 05, 2012 4:02 pm

3-colour LED module (HCMODU0057)

Post by admin » Thu Jun 05, 2014 7:38 pm

Description
This 3-colour LED module has 3 separate LED inputs (Red, Green and Blue) which can be individually driven by applying a voltage to the appropriate module pin.

PINOUT
PIN 1: RED LED +Ve
PIN 2: GREEN LED +Ve
PIN 3: BLUE LED +Ve
PIN 4: GND

CODE

Code: Select all

/* FILE:    ARD_3_COLOUR_LED_MODULE_Example
   DATE:    04/07/12
   VERSION: 0.1

This is a simple example of how to use the Hobby Components 3 colour LED module.
The module has 3 separate LED inputs (Red, Green & Blue) which can be individually 
driven by applying a voltage to the appropriate module pin. 
This example uses the standard Arduino analogWrite (PWM) function to cycle
through the full range of colours this module is capable of producing. 
Please be aware that the screen print on this module is incorrect. Please see
table below for correct pinout.

PINOUT:

PIN 1: RED LED +Ve
PIN 2: GREEN LED +Ve
PIN 3: BLUE LED +Ve
PIN 4: GND

You may copy, alter and reuse this code in any way you like, but please leave 
reference to HobbyComponents.com in your comments if you redistribute this code. 
This software may not be used directly for the purpose of selling products that 
directly compete with Hobby Components Ltd's own range of products. 

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER 
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF 
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES, 
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY 
REASON WHATSOEVER.

*/


#define BLUE_LED_DIO 11     /* Select the DIO for driving the BLUE LED */
#define RED_LED_DIO 9       /* Select the DIO for driving the RED LED */
#define GREEN_LED_DIO 10    /* Select the DIO for driving the GREEN LED */

/* Initialise serial and DIO */
void setup()
{
  /* Configure the DIO pins used by the analogWrite PWM function  */
  pinMode(BLUE_LED_DIO, OUTPUT); 
  pinMode(RED_LED_DIO, OUTPUT); 
  pinMode(GREEN_LED_DIO, OUTPUT); 
}

/* Main program loop */
void loop()
{
  int k;
  
  /* Slowly reduce the red LED's intensity and at the same time 
     increase the green LED's intensity */
  for (k = 0; k <=255; k++)
  {
    analogWrite(RED_LED_DIO,255 - k);
    analogWrite(GREEN_LED_DIO, k);  
    delay(10);
  }
  
  /* Slowly reduce the green LED's intensity and at the same time 
     increase the blue LED's intensity */
  for (k = 0; k <=255; k++)
  {
    analogWrite(GREEN_LED_DIO,255 - k);  
    analogWrite(BLUE_LED_DIO, k);  
    delay(10);
  }
  
  /* Slowly reduce the blue LED's intensity and at the same time 
     increase the red LED's intensity */
  for (k = 0; k <=255; k++)
  {
    analogWrite(BLUE_LED_DIO,255 - k); 
    analogWrite(RED_LED_DIO, k);  
    delay(10);
  }
}

Post Reply