Skip to content

Instantly share code, notes, and snippets.

@nanase
Created February 29, 2020 10:44
Show Gist options
  • Save nanase/d95081ef25bd8c10fcb0c3434f575285 to your computer and use it in GitHub Desktop.
Save nanase/d95081ef25bd8c10fcb0c3434f575285 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 50
const byte digits[] PROGMEM = {
0b11111100, // 0
0b01100000, // 1
0b11011010, // 2
0b11110010, // 3
0b01100110, // 4
0b10110110, // 5
0b10111110, // 6
0b11100000, // 7
0b11111110, // 8
0b11110110, // 9
};
void setup() {
randomSeed(analogRead(0));
pinMode(PIN_LATCH, OUTPUT);
SPI.begin();
SPI.setBitOrder(LSBFIRST);
}
void loop() {
for (int i = 0; i < 10; i++) {
digitalWrite(PIN_LATCH, LOW);
SPI.transfer(pgm_read_byte_near(digits + random(0, 9)));
digitalWrite(PIN_LATCH, HIGH);
delay(SCROLL_SPEED * random(1, 10));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment