Introduction: Arduino Common Anode 7 Segment Display

About: One man electronic band

So you went to the hardware store to get a  7 segment display to use with your arduino, and when you get home you find its common anode, not the much simpler common cathode....  you are in the right place!

In this tutorial i will show you how to wire and use a common anode display with arduino. first you must find the datasheet and find which legs are the anodes, in my case these were 3 and 8 and sorry by the way the picture is the wrong way up, so the bottom right is one and the top left is ten. the red wires are my anodes and they connect together and go to pin 2 on the arduino. The bottom four pins are connected : pin 1 on 7 segment is connected to 3 on arduino, and pin 2 is 4 etc. and on the top row : pin 5 is 7 etc, my jumper wires could not reach so the patch by the arduino is just me connecting two together.

Got everything wired in the right place? great! oh and my 7 segment is a kingsbright sa05 11ewa.

In order to light the 7 segment the common anode needs power (PIN2) and the cathodes need to reach ground, therefore by inducing a current into the cathodes you can stop them from lighting up.
This means its basically just the wrong way round, when you power the segments cathode (Cathode pin HIGH) the segment is off because it cannot reach ground, when you let the cathode reach ground (Cathode pin LOW) the segment is on, got it?

HIGH means led off, LOW means on

on is off, off is on....

I Wrote a quick piece of code to decipher which pin is which.

// this is a program attempting to light up sa05 11ewa led
// 7 bit light with common anode in series from each light

const int ANODE = 2;   // common anode pin

const int LED1 = 3;   // led 1 going right to left top to bottom
const int LED2 = 4;   // pin for led 2
const int LED3 = 5;   // pin for led 3
const int LED4 = 6;   // pin for led 4

// now bottom row

const int LED5 = 7;   // pin for led 5
const int LED6 = 8;   // pin for led 6
const int LED7 = 9;   // pin for led 7
const int LED8 = 10;  // pin for led 8

int DELAY = 0;        // so it happens only 3 times

void setup() {
  pinMode(ANODE, OUTPUT);  // common anode is obviously an output

  pinMode(LED1, OUTPUT);   // led are output for low will be on
  pinMode(LED2, OUTPUT);   // led 2 is output
  pinMode(LED3, OUTPUT);   // led 3 is output
  pinMode(LED4, OUTPUT);   // led 4 is output
  pinMode(LED5, OUTPUT);   // led 5 is output
  pinMode(LED6, OUTPUT);   // led 6 is output
  pinMode(LED7, OUTPUT);   // led 7 is output
  pinMode(LED8, OUTPUT);   // led 8 is output

void loop(){

  if (DELAY == 300){

  digitalWrite(ANODE, HIGH); // anode is recieving power

  digitalWrite(LED1, HIGH);  // stops power to led 1 
  digitalWrite(LED2, HIGH);  // stops power to led 2 
  digitalWrite(LED3, HIGH);  // stops power to led 3 
  digitalWrite(LED4, HIGH);  // stops power to led 4 
  digitalWrite(LED5, HIGH);  // stops power to led 5 
  digitalWrite(LED6, HIGH);  // stops power to led 6 
  digitalWrite(LED7, HIGH);  // stops power to led 7 
  digitalWrite(LED8, HIGH);  // stops power to led 8

delay(1000);   // delays before starting

  digitalWrite(LED1, LOW);   // turns on 1
  delay(500);                // delays
  digitalWrite(LED1, HIGH);  // turn off 1
  digitalWrite(LED2, LOW);   // turn on 2
  delay(500);                // delays
  digitalWrite(LED2, HIGH);  // turn off 2
  digitalWrite(LED3, LOW);   // turn on 3
  delay(500);                // delays
  digitalWrite(LED3, HIGH);  // turn off 3
  digitalWrite(LED4, LOW);   // turn on 4
  delay(500);                // delays
  digitalWrite(LED4, HIGH);  // turn off 4
  digitalWrite(LED5, LOW);   // turn on 5
  delay(500);                // delays
  digitalWrite(LED5, HIGH);  // turn off 4
  digitalWrite(LED6, LOW);   // turn on 5
  delay(500);                // delays
  digitalWrite(LED6, HIGH);  // turn off 4
  digitalWrite(LED7, LOW);   // turn on 5
  delay(500);                // delays
  digitalWrite(LED7, HIGH);  // turn off 4
  digitalWrite(LED8, LOW);   // turn on 5
  delay(500);                // delays
  digitalWrite(LED8, HIGH);  // turn off 4

  delay(100);                // delays

  DELAY = DELAY + 150;       // delays is increased