Last active
June 18, 2021 11:56
-
-
Save B45i/04a7e6ece09fd35af48367aad8b8f29d to your computer and use it in GitHub Desktop.
PoV Display code for ATTiny13
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
#define DELAY_TIME 2 | |
#define CHAR_BREAK 5 | |
uint8_t leds[] = { 0, 1, 2, 3, 4 }; | |
uint8_t keys[] = { 1, 2, 4, 8, 16 }; | |
void setup() { | |
for (uint8_t i = 0; i < 5; i++) { | |
pinMode(leds[i], OUTPUT); | |
} | |
} | |
uint8_t alphabets[][5] = { | |
{ 30, 5, 5, 30, 0 }, | |
{ 31, 21, 21, 10, 0 }, | |
{ 14, 17, 17, 10, 0 }, | |
{ 31, 17, 17, 14, 0 }, | |
{ 31, 21, 21, 17, 0 }, | |
{ 31, 20, 20, 16, 0 }, | |
{ 14, 17, 19, 10, 0 }, | |
{ 31, 4, 4, 4, 31 }, | |
{ 0, 17, 31, 17, 0 }, | |
{ 0, 17, 30, 16, 0 }, | |
{ 31, 4, 10, 17, 0 }, | |
{ 31, 1, 1, 1, 0 }, | |
{ 31, 12, 3, 12, 31 }, | |
{ 31, 12, 3, 31, 0 }, | |
{ 14, 17, 17, 14, 0 }, | |
{ 31, 20, 20, 8, 0 }, | |
{ 14, 17, 19, 14, 2 }, | |
{ 31, 20, 22, 9, 0 }, | |
{ 8, 21, 21, 2, 0 }, | |
{ 16, 16, 31, 16, 16 }, | |
{ 30, 1, 1, 30, 0 }, | |
{ 24, 6, 1, 6, 24 }, | |
{ 28, 3, 12, 3, 28 }, | |
{ 17, 10, 4, 10, 17 }, | |
{ 17, 10, 4, 8, 16 }, | |
{ 19, 21, 21, 25, 0 } | |
}; | |
void displayLine(uint8_t line) { | |
for (uint8_t i = 0; i < 5; i++) { | |
digitalWrite(leds[i], (line & keys[i]) == keys[i]); | |
} | |
} | |
void displayLetter(uint8_t letter[5]) { | |
for (uint8_t i = 0; i < 5; i++) { | |
displayLine(letter[i]); | |
} | |
displayLine(0); | |
} | |
void displayString(char* s) { | |
for (uint8_t i = 0; i <= strlen(s); i++) { | |
uint8_t charCode = (uint8_t)toupper(s[i]); | |
displayLetter(alphabets[(uint8_t)charCode - 97]); | |
delay(CHAR_BREAK); | |
} | |
} | |
void loop() { | |
displayString("Hello world"); | |
} | |
// Sketch uses 488 bytes (47%) of program storage space. Maximum is 1024 bytes. | |
// Global variables use 152 bytes (237%) of dynamic memory, leaving -88 bytes for local variables. Maximum is 64 bytes. | |
// Not enough memory; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing your footprint. | |
// Compilation error: Error: 2 UNKNOWN: data section exceeds available space in board | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment