Skip to content

Instantly share code, notes, and snippets.

@CLCL

CLCL/picari-01.ino

Last active Aug 29, 2015
Embed
What would you like to do?
#include <SPI.h>
#define OE 7
#define DYNA 8
#define DYNB 9
#define DATA 11
#define LATCH 10
#define CLK 13
char pattern[] = {
0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,
1,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,
0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,
0,0,1,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,
0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
1,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,
1,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
void setup() {
pinMode(LATCH, OUTPUT);
pinMode(CLK, OUTPUT);
pinMode(DATA, OUTPUT);
pinMode(DYNA, OUTPUT);
pinMode(DYNB, OUTPUT);
pinMode(OE, OUTPUT);
SPI.begin(); // SPI通信を行う為の初期化
SPI.setBitOrder(LSBFIRST); // ビットオーダー
SPI.setClockDivider(SPI_CLOCK_DIV2); // クロックをシステムクロックの1/2で使用(8MHz)
SPI.setDataMode(SPI_MODE0); // クロック極性0 クロック位相0
digitalWrite(LATCH, LOW);
delay(200) ; // 200ms後開始
}
void loop() {
for ( int i = 0; i < 4; i++) {
for ( int j = 0; j < 16; j++ ){
char s = 255;
for (int k = 0; k < 8; k++) {
s = s - (pattern[ i * 32 + ( (15 - j) % 4) * 128 + (j >> 2 ) * 8 + k] << k);
}
SPI.transfer(s);
}
digitalWrite(OE, LOW); // パネル消灯
digitalWrite(DYNA, i & 1 ); // ダイナミック点灯桁指定(LOW)
digitalWrite(DYNB, i >> 1 & 1 ); // ダイナミック点灯桁指定(HIGH)
digitalWrite(LATCH, HIGH); // ラッチ解除
digitalWrite(OE, HIGH); // パネル点灯
digitalWrite(LATCH, LOW); // ラッチ
delay(3) ; // 3msウェイト
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment