Project tutorial
Blink 2 lead bi-coloured LED

Blink 2 lead bi-coloured LED © GPL3+

For those LED's a leg short of three.

  • 1,855 views
  • 0 comments
  • 2 respects

Components and supplies

2 lead bi coloured led
×1
A000066 iso both
Arduino UNO & Genuino UNO
×1

Apps and online services

About this project

Description:

This circuit came about during some experiments I was doing in relation to building a transistor tester. Identifying the pins of a transistor using an Arduino involves altering the output pin directions and taking voltage measurements. This set me wondering, what would happen if I connected up a 2 lead bi-colored LED (with resistor) and alternated the output pin directions. I hoped the LED would alternately flash both of its colors, I was not disappointed.

Circuit description:

The circuit comprises of an Arduino (UNO) a 2 wire bi-colored LED and a 270 ohm resistor.

The resistor value used is somewhat arbitrary, I had salvaged the LED I used so I first connected it to 5 volts via a 1k resistor and measured the voltages across it (2v green, 1.6v red).

Using the standard formula (supply voltage-LED voltage drop)/current, with current set to 20 milliamps (pretty standard for LED's), gives resistor values of 150 and 170 ohms respectively for the recorded voltages.

The nearest value in my tub of components was the 270 ohm so re-arranging the formula to (supply voltage-LED voltage drop)/resistance (270 ohm) shows we have LED operating currents of 10 and 12 mA for 2 and 1.6 volts respectively, in my view this gives sufficient brightness.

Software description:

The code for this project is very simple:

In the code setup section:

We assign the 2 pins we are using as output.

In the code loop section:

We call the function which sets the output pin voltages for the led.

We delay 2 seconds.

We call our function again this time with the pin identifiers reversed.

We delay 2 seconds.

At this point we go back to the start of our loop.

The function first sets both output pins to 0 volts, this is important as you don't want both pins pushing 5 volts into each other, and then sets one pin to 5 volts before exiting.

Code

blink_bi_led.inoC/C++
/*
Test to see if you can flash 2 lead bi led using 2 ports -> you can
*/

//the pins -> red and green indicate positive connection pin for that colour
const int pin_red=2;
const int pin_green=3;

void setup() {
pinMode(pin_red,OUTPUT);
pinMode(pin_green,OUTPUT);
}

void loop() {

  set_outputs_plus_ground(pin_red,pin_green);
delay(1000);
  set_outputs_plus_ground(pin_green,pin_red);   
delay(1000);

           }

//my_functions
void set_outputs_plus_ground(int pin_plus, int pin_ground)
{
  //set both pins low first so you don't have them pushing 5 volts into eachother
  digitalWrite(pin_plus,LOW);  
  digitalWrite(pin_ground,LOW);
  //set output pin as high
  digitalWrite(pin_plus,HIGH);  
  }           

Schematics

blink_bi_led_schem_651ojXscSn.jpg
Blink bi led schem 651ojxscsn
blink_bi_led_bb_UfKirjpyOe.jpg
Blink bi led bb ufkirjpyoe

Comments

Similar projects you might like

LED Emergency Lights using WS2812 RGB LED Module

Project tutorial by bigboystoys13

  • 15,535 views
  • 7 comments
  • 34 respects

Bluetooth control led with lcd led status display real time.

Project tutorial by Youssef Sabaa

  • 28,581 views
  • 6 comments
  • 54 respects

LED Blinkies: Arduino Basics

by Alex Glow

  • 13,522 views
  • 3 comments
  • 28 respects

LED Cube

Project tutorial by Praditha Alwis

  • 11,394 views
  • 0 comments
  • 18 respects

LED Roulette Game

Project tutorial by Arduino “having11” Guy

  • 12,816 views
  • 5 comments
  • 23 respects

Not Your Typical RGB LED

by Alexander Vaughn

  • 3,554 views
  • 1 comment
  • 11 respects
Add projectSign up / Login