Skip to content

Instantly share code, notes, and snippets.

@geekman
Created September 14, 2016 13:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geekman/b5abb878443ad0cddd68aa1881602a66 to your computer and use it in GitHub Desktop.
Save geekman/b5abb878443ad0cddd68aa1881602a66 to your computer and use it in GitHub Desktop.
Arduino sketch for testing TIL311 / DIS1417 displays
/*
* TIL311 / DIS1417 tester
*
* MSB_PIN -> input D
* input C
* input B
* LSB_PIN -> input A
*
* also hook up LATCH_PIN and BLANKING_PIN accordingly
*
* 2016.09.14 darell tan
*/
// PWM pin. try to avoid 5 & 6
#define BLANKING_PIN 3
// LSB_PIN (larger) to MSB_PIN (smaller)
#define LATCH_PIN 13
#define LSB_PIN 12
#define MSB_PIN 9
void setup() {
for (int i = LSB_PIN; i >= MSB_PIN; i--)
pinMode(i, OUTPUT);
pinMode(BLANKING_PIN, OUTPUT);
analogWrite(BLANKING_PIN, 0);
pinMode(LATCH_PIN, OUTPUT);
digitalWrite(LATCH_PIN, 1);
}
static void send(unsigned int data) {
data &= 0xF;
for (int i = LSB_PIN; i >= MSB_PIN; i--) {
digitalWrite(i, data & 1);
data >>= 1;
}
// strobe it
digitalWrite(LATCH_PIN, 0);
delayMicroseconds(1); // T-setup = 40ns
digitalWrite(LATCH_PIN, 1);
}
unsigned int count = 0;
int cycleCount = 0;
int dutyCycle = 0;
void loop() {
// adjust brightness when it hits 0
if (count == 0 && ++cycleCount == 1) {
cycleCount = 0;
analogWrite(BLANKING_PIN, dutyCycle);
dutyCycle += 50;
if (dutyCycle > 255)
dutyCycle = 0;
}
send(count);
count++;
count &= 0xF;
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment