Sparkfun electronics sells some very inexpensive 4-digit led displays with an SPI -like interface. It would appear that these are no longer available at Sparkfun, but they are available from Hitt Consulting: http://www.hittconsulting.com

Here's the datasheet: pdf

Here's some code to run em:

unsigned long time;
int led_state;
char numStr[] = "0000";

#define CLOCKPIN  3  //change this to the pin where the clock is going in to
#define DATA_PIN   2  // change to the pin where the data wire is plugged in to
#define LED_PIN   13  // status led


byte digit[4];
byte number[] = {  126,   //0  numerals (0-9)
                   24,   //1
                   109,   //2
                   61,   //3
                   27,   //4
                   55,   //5
                   119,   //6
                   28,   //7
                   127,   //8
                   31,   //9
                   60,   //C
                   71,   //F
                   103,   //E
                };

void setup() {
  Serial.begin(19200);
  time = millis();
  pinMode(DATA_PIN, OUTPUT);
  pinMode(CLOCKPIN, OUTPUT);
  Serial.println("Ready");
}

void dispDigit(byte dig, byte flash) {
  for (int i = 0; i < 8; i++) {
    digitalWrite(DATA_PIN,  (dig & B10000000));    // select high bit
    dig = dig << 1;                                // next bit
    digitalWrite(CLOCKPIN, HIGH);                  // clock high
    if (flash) delay(1);                          // wait to set display on
    digitalWrite(CLOCKPIN, LOW);
  }
}

void numParse(int num) {
  itoa(num, &numStr[0], 10);
  int z = 0 ;
  if (num < 1000) {
    z++;
    digit[3] = number[0];
  }
  if (num < 100) {
    z++;
    digit[2] = number[0];
  }
  if (num < 10) {
    z++;
    digit[1] = number[0];
  }
  if (num < 1) {
    z++;
    digit[0] = number[0];
  }

  for (int g = 0; g < (4 - z); g++) digit[g] = number[numStr[3 - g - z] - 48];
}

void loop() {

  if (millis() - time > 100) {
    numParse(millis() / 100);
    for (int i = 0; i < 3; i++) dispDigit(digit[i], 0);
    dispDigit(digit[3], 1);
    time = millis();
    led_state = !led_state;
    digitalWrite(LED_PIN, led_state);
  }
}

Share