I started a project last year with the STLED316S ... and then moved, etc, etc, and didn't pick it back up again until now. Everything was already soldered up and I just needed to work on the software. But I can't get it to work. I'm not sure if it's hardware or software related, but the hardware seems okay (I know the board itself is working, but perhaps there are problems with my LCD board that has the STLED316S and the HDSP-B04E four-digit seven-segment display on it).
Does this code look like it will work?
For reference, here is the datasheet for the STLED316S: http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00181714.pdf
And, this post has my schematic for the LCD board: http://arduino.cc/forum/index.php/topic,72849.15.html
const byte LED_PIN = 6;
const byte DOUT_PIN = 2;
const byte CLK_PIN = 3;
const byte STB_PIN = 4;const byte NUM_DIGITS = 4;
const byte STB_LOW_DELAY = 0;
const byte DOUT_WRITE_DELAY = 0;boolean ledState = false;
boolean configured = false;void setup() {
//Serial.begin(57600);
pinMode(LED_PIN, OUTPUT);
pinMode(DOUT_PIN, OUTPUT);
pinMode(CLK_PIN, OUTPUT);
pinMode(STB_PIN, OUTPUT);
//Serial.println("setup complete");
}void loop() {
ledState = (ledState ? 0 : 1);
digitalWrite(LED_PIN, ledState);if (!configured) {
// CONFIGURATION
startCommand();
sendNum(B00010000); // command: 0 = unused, 0 = write, 0 = auto-inc, page: 10, addr: 000 (7-segment configuration address)
byte digits = (NUM_DIGITS - 1) & 0x03; // see datasheet - 000 = one, 001 = two, 010 = three, 011 = four, 100 = five, 101 = six
byte config = B11111000; // 111 = brightest (14/16), 11 = constant brightness, 000 = number of digits
sendNum(config | digits); // combine the config and digits into one byte
nextCommand();// TURN IT ON
sendNum(B00001101); // command: display on
nextCommand();// SEND NUMBERS
sendNum(B00000000); // command: 0 = unused, 0 = write, 0 = auto-inc, page: 00, addr: 000 (start of seven segment display)
for (byte i = 0; i < NUM_DIGITS; i++) {
sendNum(B00010000);
}
endCommand();configured = true;
}
delay(500);
}void startCommand() {
digitalWrite(CLK_PIN, LOW);
digitalWrite(STB_PIN, LOW);
delay(STB_LOW_DELAY);
}void endCommand() {
digitalWrite(STB_PIN, HIGH);
}void nextCommand() {
endCommand();
startCommand();
}void sendNum(byte num) {
//Serial.println(((int) num));for (byte i = 0; i < 8; i++) {
digitalWrite(CLK_PIN, LOW);
byte d = num & (0x1 << i);
//Serial.print(" "); //Serial.println((d ? "1" : "0"));
digitalWrite(DOUT_PIN, d);
delay(DOUT_WRITE_DELAY);
digitalWrite(CLK_PIN, HIGH);
delay(DOUT_WRITE_DELAY);
}}