

PWM is used in this sketch to fade red of the dual LED module from dim to bright, then bright to dim. switches red on, then green on, then both red and green on This sketch works the same as the previous sketch, except that it adds an extra step by leaving both red and green on for 1 second. As this program is in the main loop, it repeats continually. Green is then switched on and red off for 1 second. Red is switched on for 1 second (1000ms) and green off of the LED module in the sketch below. Also make sure that the pins have PWM capabilities when using the PWM sketch if changing the pin numbers. Pins that control the two colours can be changed at the top of the sketch, just make sure that the wiring is changed accordingly. PWM is used to control the brightness of the red then green colours of the LED in the third sketch by fading them in and out. In the second sketch first red is switched on, then green, then both red and green. The first sketch switches the two LED colours on alternately – first red then green with a delay in between. Three Arduino sketches can be found below that control the two colour LED module from the above circuit. Using two different value resistors gets the different colour LEDs approximately the same brightness. Two different value resistors are used with the two different LED colours because red and green LEDs have different forward voltages and characteristics.

The resistor serves as a current limiting resistor so that the LED does not draw too much current which could destroy it or circuitry in the microcontroller that connects to the Arduino pin. In the circuit for this tutorial, a 2k2 resistor is used on the red LED anode and a 220 Ohm resistor is used on the green LED anode. Each colour can be switched on individually, or both can be switched on at the same time. With the common anode connected to GND or negative of the power supply, the green and red LEDs can be switched on by applying the positive of the power supply to each anode through a current limiting resistor. Refer to the common cathode LED module pinout for more details.

The middle pin of the module is the anode for the red LED an the right pin of the module is the anode for the green LED. Although the middle pin of the LED itself is the common cathode, this is routed to the left pin of the module board. LED Module PinsĮach anode pin from each LED has its own pin on the LED device package. The cathode of each LED are connected together and are found on a single common pin of the LED package, hence it is a common cathode device. The two colour LED is basically two LEDs in one LED package. Principle of Operation of the Two Colour Common Cathode LED Module PWM on these pins is available, but optional, so the LED module can be switched on and off, or PWM controlled. The right pin of the LED module connects to pin 5 of the Arduino through a 220 Ohm resistor.Īrduino pins 5 and 6 were chosen to control the LEDs because they are both PWM pins. The middle pin of the LED module is connected to pin 6 of the Arduino through a 2k2 resistor. Arduino Uno and USB cable (can also use an Arduino MEGA)Ĭommon Cathode 2 Colour LED Module Arduino Circuit DiagramĪs can be seen in the circuit diagram, the left pin of the LED module is connected to a GND pin of the Arduino.
COMMON ANODE VS COMMON CATHODE HOW TO
See the circuit diagram below that shows how to connect the two colour LED module to an Arduino. Common Cathode 2 Colour LED Module Arduino Breadboard Circuit Common Cathode Dual LED Arduino Circuitīelow is an image of the circuit built on breadboard in this tutorial using an Arduino Uno. These modules may be called any one of the following, depending on which kit they are from:įor the pinout and circuit diagram of the dual colour LED module, see Geekcreit common cathode 2 colour LED module pinout reference.

Two Colour LED Modules from the 37 in 1 Sensor Kit for Arduino One module contains a 5mm LED and the other module contains a 3mm LED as shown in the image below. The 37 in 1 sensor kit module for Arduino contains two 3-pin LED modules that both have a dual colour LED. This tutorial shows basic use of the two dual colour LED modules with Arduino, first without PWM and then with PWM (Pulse Width Modulation).
