Last active
September 2, 2022 16:55
-
-
Save ryu10/caf6f124cc343c8c43c11d3e5b86d4d5 to your computer and use it in GitHub Desktop.
I got ten units of DM9368N from eBay. Test them before use.
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
void displayHex(unsigned int d0){ | |
(d0 & 0x0001)?digitalWrite(2, HIGH):digitalWrite(2, LOW); | |
(d0 & 0x0002)?digitalWrite(3, HIGH):digitalWrite(3, LOW); | |
(d0 & 0x0004)?digitalWrite(4, HIGH):digitalWrite(4, LOW); | |
(d0 & 0x0008)?digitalWrite(5, HIGH):digitalWrite(5, LOW); | |
digitalWrite(6, LOW); | |
digitalWrite(6, HIGH); // data latched | |
} | |
unsigned int data=0; | |
void setup() { | |
// put your setup code here, to run once: | |
int i; | |
for(i=2; i<8; i++){ | |
pinMode(i, OUTPUT); | |
digitalWrite(i, LOW); // DATA=0, Latch pass through, RBI enabled | |
} | |
digitalWrite(6, HIGH); // data latched | |
Serial.begin(115200); | |
Serial.write("**DM9368N Hex 7-seg Driver Test"); | |
} | |
void loop() { | |
char text[32]; | |
// put your main code here, to run repeatedly: | |
// lights on for 500ms | |
displayHex(data++); | |
sprintf(text, "display %x\n", data & 0x000f); | |
Serial.print(text); | |
digitalWrite(7, HIGH); // RBI disabled = ligths on | |
delay(500); | |
// lights off | |
displayHex(0); | |
digitalWrite(7, LOW); // RBI enabled = ligths off | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demo https://youtu.be/AXdWJetLxLQ