p4 ken
/
LED_Matrix_Japanese_Scroll
LT-5016M1を74HC595で制御します。文字スクロールなどの参考にどうぞ。
制作の過程はNotebookに書いています。
main.cpp@1:9f6c6dcdd8d7, 2016-09-08 (annotated)
- Committer:
- p4ken
- Date:
- Thu Sep 08 13:52:26 2016 +0000
- Revision:
- 1:9f6c6dcdd8d7
- Parent:
- 0:679fb5e8a0b4
- Child:
- 2:75c7836a6ff4
????????(???????)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
p4ken | 0:679fb5e8a0b4 | 1 | #include "mbed.h" |
p4ken | 0:679fb5e8a0b4 | 2 | |
p4ken | 1:9f6c6dcdd8d7 | 3 | DigitalOut RCK(PB_12);// 74HC595 |
p4ken | 1:9f6c6dcdd8d7 | 4 | DigitalOut G(PB_1); // 74HC595 |
p4ken | 1:9f6c6dcdd8d7 | 5 | DigitalOut SER(PC_6); // 74HC164 |
p4ken | 1:9f6c6dcdd8d7 | 6 | DigitalOut CLK(PC_5); // 74HC164 |
p4ken | 1:9f6c6dcdd8d7 | 7 | unsigned char pattern[2][1] = |
p4ken | 1:9f6c6dcdd8d7 | 8 | {{0b00000000}, |
p4ken | 1:9f6c6dcdd8d7 | 9 | {0b00000000}}; |
p4ken | 1:9f6c6dcdd8d7 | 10 | char scan = 16; // 点灯中の行 |
p4ken | 0:679fb5e8a0b4 | 11 | |
p4ken | 0:679fb5e8a0b4 | 12 | int main() { |
p4ken | 1:9f6c6dcdd8d7 | 13 | SPI spi(PB_15, PB_14, PB_13); |
p4ken | 1:9f6c6dcdd8d7 | 14 | spi.format(8, 0); |
p4ken | 1:9f6c6dcdd8d7 | 15 | spi.frequency(100000000); |
p4ken | 0:679fb5e8a0b4 | 16 | |
p4ken | 0:679fb5e8a0b4 | 17 | while(1) { |
p4ken | 1:9f6c6dcdd8d7 | 18 | scan++; |
p4ken | 1:9f6c6dcdd8d7 | 19 | if(scan == 17) { |
p4ken | 1:9f6c6dcdd8d7 | 20 | SER = 0; // 点灯 |
p4ken | 1:9f6c6dcdd8d7 | 21 | scan = 1; |
p4ken | 1:9f6c6dcdd8d7 | 22 | } else { |
p4ken | 1:9f6c6dcdd8d7 | 23 | SER = 1; // 消灯 |
p4ken | 0:679fb5e8a0b4 | 24 | } |
p4ken | 1:9f6c6dcdd8d7 | 25 | spi.write(pattern[0][0]); |
p4ken | 1:9f6c6dcdd8d7 | 26 | |
p4ken | 0:679fb5e8a0b4 | 27 | RCK = 0; |
p4ken | 1:9f6c6dcdd8d7 | 28 | CLK = 0; |
p4ken | 1:9f6c6dcdd8d7 | 29 | G = 1; // 消灯 |
p4ken | 0:679fb5e8a0b4 | 30 | RCK = 1; |
p4ken | 1:9f6c6dcdd8d7 | 31 | CLK = 1; |
p4ken | 1:9f6c6dcdd8d7 | 32 | G = 0; // 点灯 |
p4ken | 0:679fb5e8a0b4 | 33 | } |
p4ken | 0:679fb5e8a0b4 | 34 | } |