IC's and 4 NUMBER LED DISPLAY

So i have one of these: http://media.digikey.com/photos/Lite%20On%20Photos/LTC-4627JS,LTC-4727JS,LTC-462...

my led has 12 pins, only 11 of which id use ( i dont need the decimal). My question is, i want to reduce the amount of pins im going to need to use ( since if i plugged it into my arduino it would take up 11 digital i/o pins).

So can i buy an IC such as a atmega128/328 and put that on my arduino.. boot load it with gcc compiler, and then take that ic off and use it on a prototype board with code ive put on it? the pins on an ic such as a atmega are mostly I/O pins are they not? or is there just an easier way to do this?
The pins on the ic correspond to pins recognized by for example the digitalWrite(pin,HIGH/LOW); function right?

Also, if youve read any of my previous posts you'd know that im a big phat noob so explanations that a baby could understand is very much encouraged. Im not really sure if my if i fully understand the processors so feel free to correct me.

There are people who've used Arduinos (and Arduino-programmed chips) as I2C slaves. One of the projects on my to-do list is to use one as an I2C interface to a graphic LCD to avoid using up too many pins on the "main" Arduino.

For ideas on how to do it, check the Stripduino thread, and do a forum search for "i2c slave".

Ran

Is there a reason you're looking to do it this way instead of using a 595 shift register or similar as described in the arduino shiftOut tutorial? http://www.arduino.cc/en/Tutorial/ShiftOut

I've got to agree, the 595's would be a hell of a lot easier.

But one thing I've thought about using my extra 168 chip for was a Serial controlled LCD.. so I only need to use 2 wires from my board to control the LCD. (and well I'm sure you could use the extra I/O pins for extra inputs and outputs, controllable by the "Master" if you will!

it seems a lot more complicated then just putting a bootloader on a new atmega328 and loading code on onto it.

so with the 595 i can control each pin individually as if it were an exact replica of a digital pin on the arduino?

also in the 595 link: http://arduino.cc/en/Tutorial/ShftOut12

the author uses the variable MSBFIRST in the shiftOut() function. Where is the variable defined? and what is it?

EDIT: Ok its the bitorder i figured that much out. But whats the bit order and is it universally defined?

EDIT #2: Also the clockpin is set as pin 12, is there some automagical workings going on that connect the clock on the arduino to pin 12? I guess pin 12 is already connected to the clock, so does the function shiftOut() automatically access that information from the pin you give it?

I'm sorry, I'm not too good with the bits..
I have to say though, if you're looking at using the 595s you HAVE to look at the EarthshineDesign tutorial for them.. explains them the best, and the code they give, is awesome.
http://earthshinedesign.co.uk/ASKManual/Site/ASKManual.html
Click the picture to open the PDF and scroll down..

I don't understand the code.. at all.. and it's still very simple to set it up!

Take a look here, I just use Binary to decide which LED goes on.. for example B10000000 turns on LED number 1, B01000000 turns on the 2nd.. etc etc.. so it's very easy in terms of deciding which LED to turn on, and you're only using 3 pins!
Keep in mind, you can also use multiples as shown, but if so, you need to use shiftOut twice for two.. 3 times for 3.. etc.

Again, I don't understand most of the code at the bottom, but I added my own functions and such.
(Somebody said you can use the >> and <<, to shift the led lit left and right, instead of having to light up each LED by binary, but I haven't figured out how to change the shifted bytes yet)

I hope this helps.. it really seems much easier than using another chip! :smiley: (but what do I know?:D)

EDIT:
I forgot to mention.. you can call each LED by putting them in an array, like I did below, then using shiftOut(led[2]) to light up the third LED. (remember, arrays begin counting at 0. 0, 1, 2.. you get the point:D)

/* Taken from tutorial by Mike M at EarthshineDesign!
http://earthshinedesign.co.uk/ASKManual/Site/ASKManual.html

*/

// Project 15
//Pin connected to Pin 11 of 74HC595 (Clock)
int clockPin = 9;
//Pin connected to Pin 12 of 74HC595 (Latch)
int latchPin = 10;
//Pin connected to Pin 14 of 74HC595 (Data)
int dataPin = 11;

byte leds[] = {B10000000, B01000000, B00100000, B00010000, B00001000, B00000100, B00000010, B00000001};


void setup() {
//set pins to output
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  Serial.begin(9600);
}


void loop() {
  flashOut(150);
  wave(100);
  wave(75);
  wave(50);
  
  }
  
  
  void flashIn(int time){
    digitalWrite(latchPin, LOW);
    shiftOut(B00100100);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
    digitalWrite(latchPin, LOW);
    shiftOut(B00011000);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
  }
  
  
  void flashOut(int time){
    digitalWrite(latchPin, LOW);
    shiftOut(B10000001);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
    digitalWrite(latchPin, LOW);
    shiftOut(B01000010);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
    digitalWrite(latchPin, LOW);
    shiftOut(B11000011);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
    off(time);
    
    digitalWrite(latchPin, LOW);
    shiftOut(B11000011);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
    off(time);
  }

  void off(int time){
    digitalWrite(latchPin, LOW);
    shiftOut(B0);
    digitalWrite(latchPin, HIGH);
    delay(time);
  }

  void wave(int time){
    
    digitalWrite(latchPin, LOW);
    shiftOut(B10000001);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
    digitalWrite(latchPin, LOW);
    shiftOut(B01000010);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
    digitalWrite(latchPin, LOW);
    shiftOut(B00100100);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
    digitalWrite(latchPin, LOW);
    shiftOut(B00011000);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
    digitalWrite(latchPin, LOW);
    shiftOut(B00100100);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
    digitalWrite(latchPin, LOW);
    shiftOut(B01000010);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
    digitalWrite(latchPin, LOW);
    shiftOut(B10000001);
    digitalWrite(latchPin, HIGH);
    delay(time);
    
  }

  void shiftOut(byte dataOut) {
// Shift out 8 bits LSB first,
// on rising edge of clock
  boolean pinState;

//clear shift register ready for sending data

  digitalWrite(dataPin, LOW);
  digitalWrite(clockPin, LOW);


// for each bit in dataOut send out a bit
for (int i=0; i<=7; i++) {
  
  
//set clockPin to LOW prior to sending bit
digitalWrite(clockPin, LOW);


// if the value of DataOut and (logical AND) a bitmask
// are true, set pinState to 1 (HIGH)
if ( dataOut & (1<<i) ) {
pinState = HIGH;
}
else {
pinState = LOW;
}


//sets dataPin to HIGH or LOW depending on pinState
digitalWrite(dataPin, pinState);
//send bit out on rising edge of clock
digitalWrite(clockPin, HIGH);
}
//stop shifting out data
digitalWrite(clockPin, LOW);
}

In response to the above:

Here's how to understand the << and >>:
http://www.arduino.cc/playground/Code/BitMath

someone above sent a link to the 595 tutorial on arduino which i followed as well. The fact that the pins are represented by binary and not 1,2,3,4,etc makes so much more sense now though. Thanks for clarifying that.

The problem with using 74HC595s is that they're only rated for about 6mA out per pin. If you supply that to a 4-way-muxed display, you only get about 1.5mA average current per segment, which is probably not going be very bright. Quite possibly unacceptably so.

Ran

If you use an STP16C596 you can get up to 120mA constant current output to drive things, and it gives you 16 outputs.

Otherwise works just like two of the the regular 74xx596. :wink:

You can try also MAX7219.

Regards,
thenoble66