Created
February 29, 2020 12:51
-
-
Save nanase/3385cde2fa30f4b77871e0700857e47d to your computer and use it in GitHub Desktop.
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
#include <SPI.h> | |
#define PIN_SCK 13 | |
#define PIN_SDI 11 | |
#define PIN_LATCH 10 | |
#define SCROLL_SPEED 250 | |
const byte digits[] PROGMEM = { | |
0b11111100, // 0 | |
0b01100000, // 1 | |
0b11011010, // 2 | |
0b11110010, // 3 | |
0b01100110, // 4 | |
0b10110110, // 5 | |
0b10111110, // 6 | |
0b11100000, // 7 | |
0b11111110, // 8 | |
0b11110110, // 9 | |
0b11101110, // A | |
0b00111110, // B | |
0b00011010, // C | |
0b01111010, // D | |
0b10011110, // E | |
0b10001110, // F | |
}; | |
void setup() { | |
pinMode(PIN_LATCH, OUTPUT); | |
SPI.begin(); | |
SPI.setBitOrder(LSBFIRST); | |
} | |
void loop() { | |
for (byte i = 0; i < sizeof(digits); i++) { | |
digitalWrite(PIN_LATCH, LOW); | |
SPI.transfer(pgm_read_byte_near(digits + i)); | |
digitalWrite(PIN_LATCH, HIGH); | |
delay(SCROLL_SPEED); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment