NOOB needs help (7 segment countdown)

hi, so i dont yet own an arduino, since im not sure i would be able to code for it. (dont know C/C++)

im making a UV exposure box, and it will require a timer, the timer will count down from 600 (seconds) to 0 and when it hits 0 it will turn off the relay.

i will be using the Ardweeny, because its cheap, and i can plug it into a dip 28 socket.

The display will be a 3 digt 7-segment display, with 16 connectors (wont use the dots so only 10 in my case)

therefore they will need to be multiplexed.

the connections are:

Dpin 1 = digit 1
Dpin 2 = digit 2
Dpin 3 = digit 3

Dpin 4 = A
Dpin 5 = B
Dpin 6 = C
Dpin 7 = D
Dpin 8 = E
Dpin 9 = F
Dpin 10 = G
Dpin 11 = Relay coil

the 7-segment display is of the common anode type, and in my mind, that would meen that to turn them on, i would need to set pin 4 to 11 to low when ever i want to turn them on, and high when i wanted to turn them off.

any help would be greately appreciated :slight_smile:

Sounds like you are on track.
Go search for stopwatch or timer in the playground for code ideas.
The arduino can sink current from the cathodes (with current limit resistors in series to prevent any overcurrent damage).
You will need a transistor between +5 and the Common anode of each part - or drive the anode cirectly and limit the current thru each segment to 3mA so that if each segment is on there will only be 21mA coming out of the arduino output pin.
If the current is limited to 3mA, then any programming errors (turning on 2 or 3 anodes at once) will not damage anything as the cathode driver will only see 9mA.
You will need to do several iterations of programming & testing, be sure to leave D0 & D1 free so you can download code without your circuit interfering with the IO to/from the PC.
Once you get your code working at low current levels, you can look into higher current/brighter display, driving a transistor for the anode current and a part such as ULN2003/ULN280s for the cathode drive (or a non-inverting equivalent).
With the Tx line free, you can also send out serial messages & monitor them as a debugging aid.

thanks for the comments :slight_smile:

so im pretty sure i have the hardware side figgured now :slight_smile:

so move all the connections one pin (to leave RX and TX alone)

and have a NPN on Each Common Anode, to allow full brightness.

resistors on the cathodes to limit the current for each segment to 25 mA and a power supply.

so when this is placed in a box, where 220V are present (im in the EU) what would the easiest powersupply be?

i think i read something with placing Zener diodes, and the using the 5 volt drop (depending on the zener voltage) to power the circuit, however i can find anything about this. do you know of any alternative ultra compact 5-9-12 volt transforer solution?

i dont really want to involve other chips than the Atmega368 (the ardweeny), and i think this hardware should do the trick.

P.s. i would also have a push button to start the timer. (i dont know how)

The software however is where im stuck.

i need 600 different values displayed on the display, and the only way of displaying a something on the display for me right now would be:

int A = 5;
int B = 6;
int C = 7;
int D = 8;
int E = 9;
int F = 10;
int G = 11;
int RL = 12;
int Btn = 13;

void setup()
{
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
pinMode(E, OUTPUT);
pinMode(F, OUTPUT);
pinMode(G, OUTPUT);
pinMode(RL, OUTPUT);
pinMode(Btn, input);

}

void loop()
{
  if (digitalRead(Btn) == HIGH)

//then i would active each cathode, light the segment, delay 10 and set the next digit, this would take up massive ammounts of space and is downright stupid.

help? :astonished:
so as you can see, im pretty much running face first into a wall right now :S

Google around for EU surplus electronics shops, you should be able to find something like this that runs from 220V
http://www.mpja.com/prodinfo.asp?number=18520+PS

I'll give you a "core dump" on coding a count down timer, mostly because I don't like using some one elses uncommented cryptic shortcut C code that I can't follow (being a hardware guy for real).
This one counts down from 1:00, 3:00, or 10:00, the time preset are done elsewhere, as well as checking the start/stop button. You can modiy it to count down from 600 instead by changing the rollover amounts with a little thought
(i.e. instead of 4:00 to 3:59, go from 400 to 399)
There is a follow on section where if time_update is = to 1, then the digit displays are updated.
The first part checks if 1/4 second went by & flashes the colon on & off, if you have a start stop button you could start/stop with 1/4 second timing.
Or 1/10th second, or 1 second, or not at all, its up to you.
You'll also have to do the setup stuff, name variables, all that stuff.
currentmillis, previousmills, interval, are all unsigned long variables. (4 bytes long, 0x00 00 00 00 to 0x FF FF FF FF)

// Loop here endlessly, checking if time needs updating, 
// ***********************************************************************************************
void loop()
{
  // check if time needs updating
  if ((time_running == 1))  // fencing time is counting down or delay time is counting down
  {
    unsigned long currentMillis = millis();  // see how long its been

    if (currentMillis - previousMillis >= interval) // more than our quarter second interval?
    {
      // save the last time we okayed time updates 
      previousMillis = currentMillis; 
      quarter_interval = quarter_interval+1;
      // cycle the colon state
      if (colon == 0x80)
      {
        colon = 0x00;
      }
      else
      {
        colon = 0x80;
      }
      update_time = 1;   //  enable time display to be updated

      if (quarter_interval == 4) // we hit the one second update time
      {
        quarter_interval = 0;
        // update the time digits
        // cases: 
        // 0:01, final second - stop time, disable touch lights, sound buzzer
        // Tens of seconds rollover: time = x:50, x:40, x:30, x:20, x:10: decrement tens of seconds, rollover seconds to 9
        // Minutes rollover: time = 9:00, 8:00, etc. 2:00, 1:00: decrement ones of minutes, rollover tens of 
        // seconds to 5, ones of seconds to 9
          // 10:00: Roll all the digits over
        // otherwise: just roll over the seconds

        // Case: Final Second
        if ((minutes_ones == 0) && (seconds_tens == 0) && (seconds_ones == 1)) // don't need minutes_tens, can't have 10:01
        {
          time_running = 0;  // stop time running
          seconds_ones = 0;  // clear the last second
          updated = 1;  // fake a Case complete flag
      
        }  // end of  if final second

        // Case: x:50, x:40, x:30, x:20, x:10
        if ((seconds_tens >0) && (seconds_ones == 0))  // case for the last tens of seconds 
        {
          seconds_tens = seconds_tens - 1;  // decrement the tens
          seconds_ones = 9;  // rollover the ones
          updated = 1;
        }  // end of if 10 of seconds rollover

        // Case: 9:00, 8:00, etc 2:00, 1:00
        if ((minutes_ones > 0) && (seconds_tens == 0) && (seconds_ones == 0)) // case for the last ones of minutes
        { 
          minutes_tens = 0x00;  //
          minutes_ones = minutes_ones - 1;  // decrement the minutes
          seconds_tens = 5;  // rollover the tens of seconds;
          seconds_ones = 9;  // rollover the ones of seconds;
          updated = 1;
        } // end of if minutes rollover

        // Case: starting from 10:00
        if (minutes_tens == 0x01)  // roll over all digits
        {
          minutes_tens = 0x00;  // rollover the tens of minutes
          minutes_ones = 9;  // rollover the ones of mints;
          seconds_tens = 5;  // rollover the tens of seconds;
          seconds_ones = 9;  // rollover the ones of seconds; 
          updated = 1;
        } // end of if 10:00 rollover

        // General Case: just decrement the seconds
        if (updated == 0)  // nothing else updated - but don't decrement if = 0.
        {
          seconds_ones = seconds_ones - 1;
        }
        updated = 0;  // reset for next pass thru
      } // end of if quarter_interval
    } // end of reaching our interval
  } // end of if time_running
  else
  {
    update_time = 0;   // no time update this time around - probably don't need this
  }

okay, so since i only understand the basics i didnt understand that :~ thanks alot though :).

i found this function that Big Oil made and adapted it, im not completely sure if i need to change the for loops that resets the segments intervals, so i asked him.

however the code goes like this (my adapted version)

int i=0;
void setup()   {                  
pinMode(2, OUTPUT);  
pinMode(3, OUTPUT);  
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6, OUTPUT);  
pinMode(7, OUTPUT);  
pinMode(8, OUTPUT);  
pinMode(9,OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, INPUT);
// Using Serial.begin(9600) makes pin 1 stay HIGH for some reason [[Should be fixed]]
}

//
//

void loop()                    
{
  //NUMERAL PINS ARE 4, 5, and 9
//   4 LOW = FIRST NUMERAL [[ 2 LOW]]
//   5 LOW = SECOND NUMERAL [[3 LOW]]
//   9 LOW = THIRD NUMERAL [[4 LOW]]


  //FIRST NUMERAL ON THE DISPLAY
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);

letterfunction (7); // type 0-9 in the parenthesis or
                   //type (degree) for the degree symbol [[removed Degree (dont need it)]]
                   // or type (nothing) for nothing [[remove nothing (dont need it)]]

   //NUMERAL 2
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(9,HIGH);

letterfunction(7);


   //NUMERAL 3
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(9,LOW);

letterfunction(1); // the degree symbol [[just a random number, working on the timer (should be some simple for loop things)]]

}

//------------------------------------------------------------
// THIS FUNCTION HAS THE DIFFERENT NUMBERS
// AND THE DEGREE SYMBOL
void letterfunction(unsigned char var){
if (var==1){
digitalWrite(6,HIGH);  //pins 6 and 2 are the leftmost vertical lines
digitalWrite(7,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==2){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(11,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==3){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(11,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==4){
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);

delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==5){
digitalWrite(5,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==6){
digitalWrite(5,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
digitalWrite(7,HIGH);
digitalWrite(11,HIGH);
delay(5);

digitalWrite(5,LOW);      //Dont know why he chose to reset 
digitalWrite(10,LOW);    //like this here
digitalWrite(9,LOW);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
digitalWrite(11,LOW);

}

if (var==7){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==8){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==9){
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==0){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

}

now i only need to add a timer that takes its 3 digits and breaks it out into three different int´s

i will try and work on that. (it alot more fun if i have achieved something myself XD)

but if you have any good nifty tricks on that, it would be awesome.

And thanks A LOT for your help. i would never have ordered the ardweeny if it wasnt because of these awesome helping hands that took me into the arduino world XD

Oh yeah, almost forgot, i listend to your advise and knocked some sense into my head and found a 5v supply.
suddenly i though, "hmm 5 volts you say?... and somewhere around 550 mA.... wall to USB adapter 1000 mA! (smiles because of my idea and thinks im a genious)"

so no more life threatening hot circuit :slight_smile:

i could use a 5v zener to stablize the voltage since its a cheapo 3.7 USD chinese transformer, i think it could be unstable.

"now i only need to add a timer that takes its 3 digits and breaks it out into three different int´s"

Ok, I think my code counting down the time was commented pretty well, and I even pointed to what to change for counting down from hundreds vs minutes/seconds.
Tweak it a little and put it in front of the display code.

Heeey I think this would work :smiley: (in theory, the code might be mis written :slight_smile: )

The code:

int i=0;
boolean lastButton = LOW;
boolean currentButton = LOW;
unsigned long timeStart;
unsigned long timeCurrent = millis();

void setup()   {                  
pinMode(2, OUTPUT);  
pinMode(3, OUTPUT);  
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6, OUTPUT);  
pinMode(7, OUTPUT);  
pinMode(8, OUTPUT);  
pinMode(9,OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, INPUT);
// Using Serial.begin(9600) makes pin 1 stay HIGH for some reason [[Should be fixed]]
}

boolean debounce(boolean last)
{
  boolean current = digitalRead(12);
  if (last != current=)
  {
    delay(5);
    current = digitalRead(switchPin);
  }
  return current;

}



void loop()                    
{

currentButton = debounce(lastButton);
if (lastButton == LOW && currentButton == HIGH)
{

  digitalWrite(11, HIGH);
  
for(int x=900; x >=0; x--) //this sets the timer to count down from 900 to 0. It also sets x to the current time.
{
  int A =(x/100);              //these three lines split out the number into 3 digits, and stores them in integers.
  int B =((x/100)-(A*10))
  int C =(x-(A*100)-(B*10=));

  timeStart = timeCurrent;
  
  while ((timeCurrent-TimeStart) <=1000) //multiplexes displays for a second
  {
  
    digitalWrite(2,LOW);    //this activates the first digit on the 3 digit display, while deactivating the 2 others. (low meens on)
    digitalWrite(3,HIGH);   
    digitalWrite(4,HIGH);
  
    letterfunction (A) //call the function with the value A which was previously determined. this sets the first digit
                  
    digitalWrite(4,HIGH);   //The second digit
    digitalWrite(5,LOW);
    digitalWrite(9,HIGH);

    letterfunction(B);

    digitalWrite(4,HIGH);  //Third digit
    digitalWrite(5,HIGH);
    digitalWrite(9,LOW);

    letterfunction(C);
  }

}
  digitalWrite(11, LOW);
int lastButton =(currentButton);
}
}


//------------------------------------------------------------
// THIS FUNCTION HAS THE DIFFERENT NUMBERS
// AND THE DEGREE SYMBOL
void letterfunction(unsigned char var){
if (var==1){
digitalWrite(6,HIGH);  //pins 6 and 2 are the leftmost vertical lines
digitalWrite(7,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==2){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(11,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==3){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(11,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==4){
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);

delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==5){
digitalWrite(5,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==6){
digitalWrite(5,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
digitalWrite(7,HIGH);
digitalWrite(11,HIGH);
delay(5);

digitalWrite(5,LOW);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
digitalWrite(11,LOW);

}

if (var==7){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==8){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==9){
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

if (var==0){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
delay(5);
for(i=1;i<11;i++){
digitalWrite(i,LOW);
}
}

}

Maybe some of you out there with the items in this project at hand would be so awesome to try and run this :)?

(i need to wait for the stupid canadian mail service strike to end till they send my ardweeny)

the items are:
*3 digit 7 segment
*current limiting 1k resistors (as suggested by crossroads this limmits each segment to 3mA to be run from the arduino)
*somehow monitoring pin 11 for high low. (instead of a relay)
*a button with a pulldown resistor (10k) and a current limiting resistor on the button (100R)
*and an arduino :slight_smile:

CrossRoads:
Ok, I think my code counting down the time was commented pretty well, and I even pointed to what to change for counting down from hundreds vs minutes/seconds.
Tweak it a little and put it in front of the display code.

I just saw your post after posting mine, and i mine works its awesome, thanks for the help though :slight_smile:

you actually did help me with the timer :slight_smile:

i used the code you suggested here:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1294157511

also the timer doesnt need to be accurate, it just needs to give somewhere around 15 mins of exposure to a pcb with photoresist.

Glad to see you found a way to pull the pieces together.

a little code change (the function didnt reset all of the segemnt due to the pin shift (it was using pin 1-10 and pin 1 should be free for serial)

now the for loops in the bottom function is:

for(i=2;i<=11;i++)
{
digittalWrite(i,LOW)

the entire code is now:

int i=0;
boolean lastButton = LOW;
boolean currentButton = LOW;
unsigned long timeStart = 0;
unsigned long timeCurrent = millis();

void setup()   {                  
pinMode(2, OUTPUT);  
pinMode(3, OUTPUT);  
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);  
pinMode(7, OUTPUT);  
pinMode(8, OUTPUT);  
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, INPUT);
pinMode(13, OUTPUT);

}

boolean debounce(boolean last)
{
  boolean current = digitalRead(12);
  if (last != current)
  {
    delay(5);
    current = digitalRead(12);
  }
  return current;

}



void loop()                    
{

currentButton = debounce(lastButton);
if (lastButton == LOW && currentButton == HIGH)
{

  digitalWrite(13, HIGH);
  
for(int x=900; x >=0; x--) //this sets the timer to count down from 900 to 0. It also sets x to the current time.
{
  int A =(x/100);              //these three lines split out the number into 3 digits, and stores them in integers.
  int B =((x/10)-(A*10));
  int C =(x-(A*100)-(B*10));

  timeStart = timeCurrent;
  
  while ((timeCurrent-timeStart) <=1000) //multiplexes displays for a second
  {
  
    digitalWrite(2,LOW);    //this activates the first digit on the 3 digit display, while deactivating the 2 others. (low meens on)
    digitalWrite(3,HIGH);   
    digitalWrite(4,HIGH);
  
    letterfunction (A); //call the function with the value A which was previously determined. this sets the first digit
                  
    digitalWrite(4,HIGH);   //The second digit
    digitalWrite(5,LOW);
    digitalWrite(9,HIGH);

    letterfunction(B);

    digitalWrite(4,HIGH);  //Third digit
    digitalWrite(5,HIGH);
    digitalWrite(9,LOW);

    letterfunction(C);
  }

}
  digitalWrite(13, LOW);
int lastButton =(currentButton);
}
}


//------------------------------------------------------------
// THIS FUNCTION HAS THE DIFFERENT NUMBERS
// AND THE DEGREE SYMBOL
void letterfunction(unsigned char var){
if (var==1){
digitalWrite(6,HIGH);  //pins 6 and 2 are the leftmost vertical lines
digitalWrite(7,HIGH);
delay(5);
for(i=2;i<=11;i++){
digitalWrite(i,LOW);
}
}

if (var==2){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(11,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
delay(5);
for(i=2;i<=11;i++){
digitalWrite(i,LOW);
}
}

if (var==3){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(11,HIGH);
delay(5);
for(i=2;i<=11;i++){
digitalWrite(i,LOW);
}
}

if (var==4){
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);

delay(5);
for(i=2;i<=11;i++){
digitalWrite(i,LOW);
}
}

if (var==5){
digitalWrite(5,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(5);
for(i=2;i<=11;i++){
digitalWrite(i,LOW);
}
}

if (var==6){
digitalWrite(5,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
digitalWrite(7,HIGH);
digitalWrite(11,HIGH);
delay(5);

digitalWrite(5,LOW);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
digitalWrite(11,LOW);

}

if (var==7){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
delay(5);
for(i=2;i<=11;i++){
digitalWrite(i,LOW);
}
}

if (var==8){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
delay(5);
for(i=2;i<=11;i++){
digitalWrite(i,LOW);
}
}

if (var==9){
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
delay(5);
for(i=2;i<=11;i++){
digitalWrite(i,LOW);
}
}

if (var==0){
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
delay(5);
for(i=2;i<=11;i++){
digitalWrite(i,LOW);
}
}

}

ok so i now have a problem....

i suspect the problems lies where i call the letterfunction. the letterfunction is setup to store the recived data in a unsigned char, i need to call it with a variable and call it like this:

letterfunction(A)

i suspect that it reads that as an A and not as the integer value it has :frowning:

if you need to know what the symptoms are, it just flashes 888 all the time :frowning:

Ok, Maybe two things:
in this section

while ((timeCurrent-timeStart) <=1000) //multiplexes displays for a second
  {
  
    digitalWrite(2,LOW);    //this activates the first digit on the 3 digit display, while deactivating the 2 others. (low meens on)
    digitalWrite(3,HIGH);   
    digitalWrite(4,HIGH);  <<<< Should these be 4,5,9 like the next two?? If you gave the pins names, such as
2 = digitA
3 = digitB
4 = digitC
5 = SegmentA
6 = SegmentB
7 = SegmentC
8 = SegmentD
9 = SegmentE
10 = SegmentF
11 = SegmentG,
then used those names, errors like this wouldn't crop up
  
    letterfunction (A); //call the function with the value A which was previously determined. this sets the first digit
                  
    digitalWrite(4,HIGH);   //The second digit
    digitalWrite(5,LOW);
    digitalWrite(9,HIGH);

    letterfunction(B);

    digitalWrite(4,HIGH);  //Third digit
    digitalWrite(5,HIGH);
    digitalWrite(9,LOW);

    letterfunction(C);
  }

}

you will cycle thru the three digits very quickly.

and then in this section

if (var==9){
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
delay(5);
for(i=2;i<=11;i++){
digitalWrite(i,LOW);
}

the segments are turned on, but the for loop just turns them all off again 5 mS later. Try making your display time longer.
Or put 7 writes in for each character so that each are commanded high/low as needed. They segments are already turned off by the digit cycling in the first part, you don't need to clear all of them after each display.

Another thing you can do that I think would help is to use switch:case structure:

switch(var){
case 0:
write the segments high/low for a 0
break;
case 1:
write the segments high/low for a 0
break;
etc. 
case 9:
write the segments high/low for a 9
break;
}

Then you are not making 9 comparisons every time to find the 1 digit you want, that you are flashing on for 5mS.

ok so i still have problems

i show them in this video:

Ok, the video helps some - post your whole code again.
I think you're pretty close.

uploaded it to a txt file here http://snuletek.com/ting/code.txt

its also there |
/

/*
okay so this code is used for a 3 digit 7 segment display multiplexed.
it counts down from 900 (seconds) to 0, in the begining it turns on pin 13 (which is a npn transistor controlling a relay)

the segments are common anode, the way its controlled is by 3 pnp transistors on the anodes and 7 npn on the cathodes.
*/

unsigned long timeStart;        //setting up the variables used globaly
boolean lastButton = LOW;       
boolean currentButton = LOW;

void setup()                    //setting up the pins for the segments button and relay
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, INPUT);
  pinMode(13, OUTPUT);
  Serial.begin(9600);
}

boolean deBounce (boolean last)          //a debounce function as shown in sciguy14´s arduino tutorial 06
{                                        //( http://www.youtube.com/watch?v=g0pSfyXOXj8 )
  boolean current = digitalRead(12);
  if (last != current)
  {
    delay(5);
  current = digitalRead(12);
  }
  return current;
}

void number(int var)
{
  switch(var)
  {
    case 0:
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    break;
    
    case 1:
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(5, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    break;
    
    case 2:
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(11, LOW);
    break;
    
    case 3:
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(11, LOW);
    digitalWrite(9, LOW);
    break;

    case 4:
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(5, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);   
    break;
    
    case 5:
    digitalWrite(5, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(6, LOW);
    break;   
    
    case 6:   
    digitalWrite(5, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, LOW);
    break;
    
    case 7:
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(9, LOW);
    digitalWrite(8, LOW);
    break;
    
    case 8:
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    break;
    
    case 9:
    digitalWrite(10, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, LOW);
    break;
   
  }
}
  
/*  if (var == 10)
  {
    for (int i=5; i <12; i++)
      {
        digitalWrite(i, LOW);
      }     
  }   
  
  if (var == 0)
  {
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(11, HIGH);
  }
    
  if (var == 1)
  {
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
  }
  
  if (var == 2)
  {
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
  }
  
  if (var == 3)
  {
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
 }
  
  if (var == 4)
  {
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
  }
  
  if (var == 5)
  {
    digitalWrite(5, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
  }
  
  if (var == 6)
  {
    digitalWrite(5, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
  }
  
  if (var == 7)
  {
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
  }
  
  if (var == 8)
  {
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, HIGH);
  }
  
  if (var == 9)
  {
    digitalWrite(10, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
  }
}
*/
void loop()
{
  digitalWrite(2, HIGH);
  digitalWrite(3, HIGH);
  digitalWrite(4, HIGH);
  
  //currentButton = deBounce(lastButton);                  //Using the debounce function to see if the button has been pushed
  //if (lastButton == LOW && currentButton == HIGH)
  //{
    digitalWrite(13, HIGH);                              //turns on the relay
      
    for(int x=900; x >=0; x--)                           //starts the timer at 900 seconds
    {
      int A = x/100;                                     //splits the int x (the current second) into three individual int´s
      int B = x/10 - A*10;                               //needed to send to the displays
      int C = x - A*100 - B*10;
      Serial.print(A);
      Serial.print(B);
      Serial.println(C);
      timeStart = millis();                              //sets the unsigned long timeStart to the current millis()
                                                         //(read about millis on the arduino site)
     
      while ((millis() - timeStart) <= 1000)             //runs this loop while millis() - timeStart) is less than or equal to 1 second
      {                                                  
         
        
        digitalWrite(2, LOW);
        digitalWrite(3, HIGH);
        digitalWrite(4, HIGH);
        number(A);
        delay(10);
        
                                        
        digitalWrite(2, HIGH);
        digitalWrite(3, LOW);
        digitalWrite(4, HIGH);
        number(B);        
        delay(10);
     
                                       
        digitalWrite(2, HIGH);
        digitalWrite(3, HIGH);
        digitalWrite(4, LOW);
        number(C); 
        delay(10);
        

      }
    }
  //}
}

You don't have the transistors wired in place yet, do you? I'll look at your video again to confirm.

If that's the case, all the Highs & Lows for pins 2-3-4 and 5-6-7-8-9-10-11 need to be swapped :
2 High turns on CommonAnode2, while 5-6-7-8-9-10-11 low would bring the Cathodes Low & make an 8 appear.

If you do have the transisters, than post the schematic, is hard to tell what you have from the brief camera glimpse.

Minor thing; you don't turn the relay off when done.

http://snuletek.com/ting/adsgf.png

dont know if the arrows are correct, however the hardware works. tested it by manualy setting pnp low and npn high

switch(var)
  {
    case 0:
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    break;

Have you got an aversion to arrays and for loops, or do you just enjoy typing?

@Awol,
Writing out the digits may look a little longhand, but it should work okay.

Any ideas as to why the digits don't appear to be changing?
Does the cycle time just need to be slowed down some more?