I have a few code samples that are similar to what I've pasted below. What I want to know is how to control the led to write text or specific numbers, etc. It seems like the answer is in the shiftOut, dataOut, functions, but I just don't have a handle on it yet.
#define CLOCKPIN 12 //change this to the pin where the clock is going in to
#define DATA_PIN 13 // change to the pin where the data wire is plugged in to
int time = 2400;
int digits[10] = { 126, 24, 109, 61, 27, 55, 119, 28, 127, 31 }; // define numerals (0-9)
int digitC = 60;
int digitF = 71;
int digitE = 103;
int flashDelay = 1400;
int minDelay = 500;
char* numStr = " ";
void setup()
{
Serial.begin(9600);
pinMode(DATA_PIN, OUTPUT);
pinMode(CLOCKPIN, OUTPUT);
}
void numOut(int num){
int g;
char* *numStrPtr;
//char *numDigitPtr;
numStrPtr = &numStr;
//numDigitPtr = &numDigit;
itoa(num, *numStrPtr, 10);
for (g=3; g >= 0; g--) {
if (g == 0) {
digitOut(digits[numStr[g]-48], flashDelay);
} else {
digitOut(digits[numStr[g]-48], minDelay);
}
}
}
void digitOut(byte dataOut, int curDelay) {
// This shifts bits out MSB first, on the rising edge of the clock:
int i; // bit counter
if (curDelay < minDelay) { curDelay = minDelay; } // delay
for (i=7; i>=0; i--) {
if ( dataOut & (1<<i) ) {
digitalWrite(DATA_PIN, HIGH);
}
// if this bit of the dataOut variable is a 0,
// then set the data pin low to shift out a 0:
else {
digitalWrite(DATA_PIN, LOW);
}
digitalWrite(CLOCKPIN, HIGH);
// pulse the clock:
if (i == 0) {
delayMicroseconds(curDelay);
} else {
delayMicroseconds(minDelay);
}
digitalWrite(CLOCKPIN, LOW);
}
}
void loop()
{
time = time - 1;
numOut(time); //use this function to display what you want to display
//Serial.println(time);
delay(1000);
}