Last active
April 9, 2019 18:26
-
-
Save jazari-akuna/611cd8d9eff86a0bf996bd5277a12c94 to your computer and use it in GitHub Desktop.
TIL311 educational, slapped together code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// EDUCATIONAL CODE. Do What the Fuck You Want to Public License. | |
// Just a quick code to explain how the TIL311 hexa display works. | |
// I do not have it anymore, this is just based on the datasheet so no means of testing. | |
// This is not object-oriented or uC-style for education purpose. | |
// You will have to connect pins 1 and 14 of TIL311 to Vcc (5V) | |
// pin 7 to ground. | |
// Datasheet: https://www.jameco.com/Jameco/Products/ProdDS/32951.pdf for reference. | |
#define LSTROBE 3 // TIL311 pin 5. If HIGH, the TIL311 will not be affected by inputs. Useful for multiplexing. | |
#define BLANK 4 // To pin 8. To blank the screen, can be used to modulate intensity | |
#define LDP 5 // To pin 4. Left decimal point, put LOW to light up | |
#define RDP 6 // To pin 10. Right decimal point, same | |
const byte dataPins[] = {7,8,9,10}; // TIL311 binary inputs | |
// Connect to 3, 2, 13, 12, in this order, see datasheet page 2 | |
int disp=0; // Displayed number | |
void setup() | |
{ | |
for (int i=0; i<4; ++i){ | |
pinMode(dataPins[i], OUTPUT); | |
} | |
pinMode(LSTROBE, OUTPUT); | |
pinMode(BLANK, OUTPUT); | |
pinMode(LDP, OUTPUT); | |
pinMode(RDP, OUTPUT); | |
digitalWrite(LSTROBE, LOW); | |
digitalWrite(BLANK, LOW); | |
// Decimal points off | |
digitalWrite(LDP, HIGH); | |
digitalWrite(RDP, HIGH); | |
} | |
void loop() | |
{ | |
for (int i=0; i<4; ++i){ | |
digitalWrite(dataPins[i], bitRead(disp, i)); | |
} | |
disp++; // Same as disp = disp + 1; | |
if (16 == disp) // This is a hexadecimal display | |
disp = 0; | |
delay(1000); // Wait one second | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment