Arduino programmed ATiny84 controlling a 7 segment display!

Hey guys, I've just got my Arduino Uno R3 a few days ago and began playing with it. javascript:void(0);
One of my first projects I've created was a 7 segment display (from RadioShack) with two buttons: one that increases the digit by one and the other decreases it by one.

I then found a turtorial on programming an Attiny micro microcontroller which really got my attention. I then ordered two Attiny85's and one Attiny84 for just 3.04$ from http://www.newark.com !! :astonished:

So I started messing around with these little fellows and then decided to implement one of the chips (particulary the Attiny84 because it has 10 functional pins compared to 5 pins in Attiny85 ) in my segment display project! 8)

What I used:

Due to some unexplainable dificulties I just left only the button that increases the digit but I was still exited seeing my project not connected to my Arduino anymore! :%

int aPin = 7; // a segment 
int bPin = 6; // b segment
int cPin = 2; // c segment
int dPin = 3; // and so on....
int ePin = 4;
int fPin = 5;
int gPin = 8;

int upPin = 9; // button connection.

int ledPin = 10; // led connection. this is really optional, i just added it for debuging

int count = 0;
int d = 250; // delay, experiment with it so you'll see what it is. 

void setup ()
{
  pinMode(aPin, OUTPUT);
  pinMode(bPin, OUTPUT);
  pinMode(cPin, OUTPUT);
  pinMode(dPin, OUTPUT);
  pinMode(ePin, OUTPUT);
  pinMode(fPin, OUTPUT);
  pinMode(gPin, OUTPUT);
  
  pinMode(upPin, INPUT);
  
  zero ();
  
}

void loop ()
{
  int up  = digitalRead(upPin); 
  
  if ( up == 0)
  {
    digitalWrite (ledPin, HIGH);
    off();
    count ++;
    
     if (count == 1)
    {
      off();
      one ();
    }    
     if (count  == 2)
    {
      off();
      two ();
    }  
     if (count == 3)
    {
      off();
      three ();
    }
     if (count == 4)
    {
      off();
      four ();
    }    
     if (count == 5)
    {
      off();
      five ();
    }    
     if (count == 6)
    {
      off();
      six ();
    }    
     if (count == 7)
    {
      off();
      seven ();
    }   
     if (count == 8)
    {
      off();
      eight ();
    }   
     if (count == 9)
    {
      off();
      nine ();
    }    
     if (count == 0)
    {
      off();
      zero ();
    }    
     if (count > 9)
    {
      count = 0;
      zero ();
    }    
    delay (d);  
   digitalWrite (ledPin, LOW); 
  }
  
}

void off ()
{
  digitalWrite(aPin, LOW);
  digitalWrite(bPin, LOW);
  digitalWrite(cPin, LOW);
  digitalWrite(dPin, LOW);
  digitalWrite(ePin, LOW);
  digitalWrite(fPin, LOW);
  digitalWrite(gPin, LOW);
}

void one ()
{
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
}

void two ()
{
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(gPin, HIGH);
  digitalWrite(dPin, HIGH);
  digitalWrite(ePin, HIGH);
}

void three ()
{
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, HIGH);
  digitalWrite(gPin, HIGH);
}

void four ()
{
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(gPin, HIGH);
  digitalWrite(fPin, HIGH);
}

void five ()
{
  digitalWrite(aPin, HIGH);
  digitalWrite(fPin, HIGH);
  digitalWrite(gPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, HIGH);
}

void six ()
{
  digitalWrite(aPin, HIGH);
  digitalWrite(fPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, HIGH);
  digitalWrite(ePin, HIGH);
  digitalWrite(gPin, HIGH);
}

void seven ()
{
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
}

void eight ()
{
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, HIGH);
  digitalWrite(ePin, HIGH);
  digitalWrite(fPin, HIGH);
  digitalWrite(gPin, HIGH);
}

void nine ()
{ digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(fPin, HIGH);
  digitalWrite(gPin, HIGH);
}

void zero ()
{
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, HIGH);
  digitalWrite(ePin, HIGH);
  digitalWrite(fPin, HIGH);
}

HELPFUL SOURCE!!
http://hlt.media.mit.edu/?p=1695

Here are the sources you'll find helpful:

THANK YOU FOR VIEWING!! PLEASE COMMENT!!

if (count == 8)

Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the # button above the posting area.

(You may need to grab the actual source code, don't use "copy for forum".)

Also please remove the sideways scrolling text, it's rather distracting.

Alright now?

Thank you very much!

If you are having trouble with the buttons you could post a query in the Programming section, someone may be able to help you.

Oooo. Ok thanks! :wink:

Very good, you should resize your photo`s though. :slight_smile:

Some ATtiny links here
http://www.kobakant.at/DIY/?p=3408