/* * EXAMPLE FIRMWARE FOR THE LARGE 7-SEGMENT DISPLAY * driver IC: STP16C26 * author: martin@embedblog.eu * see the listing at https://www.tindie.com/products/edit/dual-large-7-segment-display-w-cc-driver/ * Arduino-compatible example (modify the defines on top to suit your device - this waas written for STM32 BluePill, but should work on any Arduino board) * Connect power either via the IDC 6-pin, 8-pin header or the DC jack (all the 12 V pins are connected together!) * Send data either via the IDC-pin or the 8-pin header */ #define CLK_PIN PB8 #define DIN_PIN PB5 #define LAT_PIN PB6 #define OE_PIN PB7 //if you are not using the OE pin for dimming, tie it to ground #define DIGITS 2 //how many digits are to be displayed (ie number of boards times 2) char buffer[DIGITS]; byte decimal_point = 1; //position of the decimal point (from left) //this function provides simple translation between ASCII chars and data for the display byte translate_ascii(char c) { switch (c) { case '0': return 0b11111100; case '1': return 0b01100000; case '2': return 0b11011010; case '3': return 0b11110010; case '4': return 0b01100110; case '5': return 0b10110110; case '6': return 0b10111110; case '7': return 0b11100000; case '8': return 0b11111110; case '9': return 0b11110110; default: return 0b00000010; } } void setup() { //setup GPIO as outputs pinMode(PC13, OUTPUT); pinMode(CLK_PIN, OUTPUT); pinMode(DIN_PIN, OUTPUT); pinMode(LAT_PIN, OUTPUT); pinMode(OE_PIN, OUTPUT); analogWrite(OE_PIN, 0); //fill the buffer with chars we want to display buffer[0] = '8'; buffer[1] = '1'; //this part actually sends out the data for (byte i = 0; i < DIGITS; i++) shiftOut(DIN_PIN, CLK_PIN, LSBFIRST, translate_ascii(buffer[i]) | ((decimal_point - 1) == i ? 0b1 : 0b0)); digitalWrite(LAT_PIN, HIGH); digitalWrite(LAT_PIN, LOW); } void loop() {} /* in case you don't have the shiftOut function: void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val) { uint8_t i; for (i = 0; i < 8; i++) { if (bitOrder == LSBFIRST) digitalWrite(dataPin, !!(val & (1 << i))); else digitalWrite(dataPin, !!(val & (1 << (7 - i)))); digitalWrite(clockPin, HIGH); digitalWrite(clockPin, LOW); } } */