Created
February 29, 2020 11:52
-
-
Save nanase/f360798cf279151dd2967600f1f27e0f 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 10 | |
const byte digits[] PROGMEM = { | |
0b10000000, // 1 | |
0b01000000, // 2 | |
0b00100000, // 3 | |
0b00010000, // 4 | |
0b00001000, // 5 | |
0b00000100, // 6 | |
}; | |
void setup() { | |
randomSeed(analogRead(0)); | |
pinMode(PIN_LATCH, OUTPUT); | |
SPI.begin(); | |
SPI.setBitOrder(LSBFIRST); | |
} | |
void loop() { | |
for (int j = 10; j > 0; j--) { | |
for (int k = 0; k < 10; k++) { | |
for (int 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 * j); | |
} | |
} | |
} | |
digitalWrite(PIN_LATCH, LOW); | |
SPI.transfer(0); | |
digitalWrite(PIN_LATCH, HIGH); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment