Skip to content

Instantly share code, notes, and snippets.

@nanase
Created February 29, 2020 11:52
Show Gist options
  • Save nanase/f360798cf279151dd2967600f1f27e0f to your computer and use it in GitHub Desktop.
Save nanase/f360798cf279151dd2967600f1f27e0f to your computer and use it in GitHub Desktop.
#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