That is an SPI interface. Using multiples should be easy. Each one has a CS pin. When that pin is pulled low it selects that chip as the one you are talking to. Several displays could all share the CLK, DIN, and DOUT pins on the Arduino and each would have it's own pin on the Arduino for CS. To update any given display, you pull its CS pin low and then transmit your data. If you pull the CS pins on two displays low at the same time you'll send the data to both. Whichever has the CS pin pulled low on it is the one that listens.
Google SPI and do a little investigation on SPI with Arduino. That will help you learn a little about how SPI works and you will certainly get your question fully answered about how to drive multiple chips while sharing pins. Driving multiple things with the same pins is the whole point of SPI.
The connection would look like this for an UNO -
Pin 13 ---- CLK pin on all chips
Pin 12 ---- DOUT on all chips
Pin 11 ---- DIN on all chips
Choose a different pin on Arduino for each chip and connect to the CS pin.
To use SPI, pin 10 MUST be configured as an output. It cannot be an input. So it would be a good idea to use 10 for one of the CS pins just to make sure it is going to stay an output.
EDIT:
I just looked at the page you linked to and it looks like the library you are using isn't using the SPI hardware but is bit-banging SPI from software using other pins. The concept is still the same, all share CK and DIN and the CS pin picks the one you're talking to.
The code would be a lot faster and much more compact if you changed this library to use the SPI hardware instead of software. It just limits which pins you have to use to the ones I listed above.
EDIT AGAIN:
I feel generous and it was really really really easy to do so I switched his code to run on the SPI hardware. It compiles but hasn't been tested. It should work though. Hooking DOUT to pin 12 is optional, but you still can't use pin 12 for anything else so you might as well.
PT6961_SPI.h
/*
PT6961.h - Library for communicating with PT6961 LED driver.
Created by Garrett Blanton January, 16, 2013.
Released into the public domain.
*/
#ifndef PT6961_SPI_H_
#define PT6961_SPI_H_
#include "Arduino.h"
#include <SPI.h>
class PT6961
{
public:
PT6961(uint8_t CS);
void initDisplay();
void initRAM();
void sendCmd(char cmd);
void sendDigit(char digit, char val);
void sendNum(int num, char colon);
void sendDigits(char digit1, char digit2, char digit3, char digit4, char colon);
const static char _DISPLAY_6X12 = 0x02;
const static char _DISPLAY_7X11 = 0x03;
const static char _AUTO_INCREMENT = 0x40;
const static char _FIXED_ADDRESS = 0x44;
const static char _DISPLAY_OFF = 0x80;
const static char _DISPLAY_1_16 = 0x88;
const static char _DISPLAY_2_16 = 0x89;
const static char _DISPLAY_4_16 = 0x8A;
const static char _DISPLAY_10_16 = 0x8B;
const static char _DISPLAY_11_16 = 0x8C;
const static char _DISPLAY_12_16 = 0x8D;
const static char _DISPLAY_13_16 = 0x8E;
const static char _DISPLAY_14_16 = 0x8F;
private:
uint8_t _CS;
};
#endif
PT6961_SPI.cpp
/*
PT6961.cpp - Library for communicating with PT6961 LED driver.
Created by Garrett Blanton January, 16, 2013.
Released into the public domain.
*/
//0 - A
//1 - B
//2 - C
//3 - D
//4 - E
//5 - F
//6 - G
//7 - Colon
#include "Arduino.h"
#include "PT6961_SPI.h"
PT6961::PT6961(uint8_t CS) {
pinMode(CS, OUTPUT);
_CS = CS;
SPI.begin();
SPI.setBitOrder(LSBFIRST);
}
void PT6961::initDisplay() {
sendCmd(_DISPLAY_6X12);
sendCmd(_AUTO_INCREMENT);
initRAM();
sendCmd(_DISPLAY_14_16);
}
// Initializes RAM to all zeros
void PT6961::initRAM() {
//first clear 8 bytes of the display RAM
digitalWrite(_CS, LOW);
// shiftOut(_DIN, _CLK, LSBFIRST, 0xC0);
SPI.transfer(0xC0);
for (int i = 0; i < 8; i++) {
// shiftOut(_DIN, _CLK, LSBFIRST, 0x00);
SPI.transfer(0x00);
}
digitalWrite(_CS, HIGH);
}
// Use to send command based on enumeration
void PT6961::sendCmd(char cmd) {
digitalWrite(_CS, LOW);
// shiftOut(_DIN, _CLK, LSBFIRST, cmd);
SPI.transfer(cmd);
digitalWrite(_CS, HIGH);
}
void PT6961::sendDigit(char digit, char val) {
digitalWrite(_CS, LOW);
// shiftOut(_DIN, _CLK, LSBFIRST, digit);
// shiftOut(_DIN, _CLK, LSBFIRST, val);
SPI.transfer(digit);
SPI.transfer(val);
digitalWrite(_CS, HIGH);
}
void PT6961::sendNum(int num, char colon) {
int digit1 = num / 1000;
int digit2 = (num % 1000) / 100;
int digit3 = (num % 100) / 10;
int digit4 = (num % 10);
sendDigits(digit1, digit2, digit3, digit4, colon);
}
void PT6961::sendDigits(char digit1, char digit2, char digit3, char digit4,
char colon) {
const char DISP[17] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07,
0x7f, 0x6f, 0x77, 0x7c, 0x58, 0x5e, 0x79, 0x71, 0x61 };
digitalWrite(_CS, LOW);
// shiftOut(_DIN, _CLK, LSBFIRST, 0xC0);
SPI.transfer(0xC0);
if (colon == 1) {
// shiftOut(_DIN, _CLK, LSBFIRST, DISP[digit1] | 0x80);
SPI.transfer(DISP[digit1] | 0x80);
} else {
// shiftOut(_DIN, _CLK, LSBFIRST, DISP[digit1]);
SPI.transfer(DISP[digit1]);
}
// shiftOut(_DIN, _CLK, LSBFIRST, 0xC2);
SPI.transfer(0xC2);
if (colon == 1) {
// shiftOut(_DIN, _CLK, LSBFIRST, DISP[digit2] | 0x80);
SPI.transfer(DISP[digit2] | 0x80);
} else {
// shiftOut(_DIN, _CLK, LSBFIRST, DISP[digit2]);
SPI.transfer(DISP[digit2]);
}
// shiftOut(_DIN, _CLK, LSBFIRST, 0xC4);
SPI.transfer(0xC4);
// shiftOut(_DIN, _CLK, LSBFIRST, DISP[digit3]);
SPI.transfer(DISP[digit3]);
// shiftOut(_DIN, _CLK, LSBFIRST, 0xC6);
SPI.transfer(0xC6);
// shiftOut(_DIN, _CLK, LSBFIRST, DISP[digit4]);
SPI.transfer(DISP[digit4]);
digitalWrite(_CS, HIGH);
}
Example.ino
#include "Arduino.h"
#include <SPI.h>
#include "PT6961_SPI.h"
PT6961 LED(10); /// This is the pin number for CS pin on each chip
// PT6961 LED2(9); // The next might look like this if it were connected to pin 9
void setup()
{
LED.initDisplay();
Serial.begin(9600);
}
void loop()
{
//count through 0-9,a-f
for(int i=0; i<16; i++)
{
LED.sendDigits(0,0,0,i,0);
Serial.println(i);
delay(500);
}
}