p4 ken
/
LED_Matrix_Japanese_Scroll
LT-5016M1を74HC595で制御します。文字スクロールなどの参考にどうぞ。
制作の過程はNotebookに書いています。
main.cpp@0:679fb5e8a0b4, 2016-09-07 (annotated)
- Committer:
- p4ken
- Date:
- Wed Sep 07 10:32:48 2016 +0000
- Revision:
- 0:679fb5e8a0b4
- Child:
- 1:9f6c6dcdd8d7
2????
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 | 0:679fb5e8a0b4 | 3 | DigitalOut RCK(PB_12); |
p4ken | 0:679fb5e8a0b4 | 4 | DigitalOut G(PB_1); |
p4ken | 0:679fb5e8a0b4 | 5 | DigitalOut SER(PC_6); |
p4ken | 0:679fb5e8a0b4 | 6 | DigitalOut CLK(PC_5); |
p4ken | 0:679fb5e8a0b4 | 7 | |
p4ken | 0:679fb5e8a0b4 | 8 | int main() { |
p4ken | 0:679fb5e8a0b4 | 9 | SPI spi0(PB_15, PB_14, PB_13); //あ |
p4ken | 0:679fb5e8a0b4 | 10 | spi0.format(8, 0); |
p4ken | 0:679fb5e8a0b4 | 11 | spi0.frequency(100000000); |
p4ken | 0:679fb5e8a0b4 | 12 | G = 0; |
p4ken | 0:679fb5e8a0b4 | 13 | SER = 0; // 0=ON 1=OFF |
p4ken | 0:679fb5e8a0b4 | 14 | CLK = 0; |
p4ken | 0:679fb5e8a0b4 | 15 | CLK = 1; |
p4ken | 0:679fb5e8a0b4 | 16 | |
p4ken | 0:679fb5e8a0b4 | 17 | int count = 0; |
p4ken | 0:679fb5e8a0b4 | 18 | while(1) { |
p4ken | 0:679fb5e8a0b4 | 19 | for(int i=0; i<20; i++){ |
p4ken | 0:679fb5e8a0b4 | 20 | switch(count){ |
p4ken | 0:679fb5e8a0b4 | 21 | case 0: spi0.write(0b00000001); break; |
p4ken | 0:679fb5e8a0b4 | 22 | case 1: spi0.write(0b00000010); break; |
p4ken | 0:679fb5e8a0b4 | 23 | case 2: spi0.write(0b00000100); break; |
p4ken | 0:679fb5e8a0b4 | 24 | case 3: spi0.write(0b00001000); break; |
p4ken | 0:679fb5e8a0b4 | 25 | case 4: spi0.write(0b00010000); break; |
p4ken | 0:679fb5e8a0b4 | 26 | case 5: spi0.write(0b00100000); break; |
p4ken | 0:679fb5e8a0b4 | 27 | case 6: spi0.write(0b01000000); break; |
p4ken | 0:679fb5e8a0b4 | 28 | case 7: spi0.write(0b10000000); break; |
p4ken | 0:679fb5e8a0b4 | 29 | } |
p4ken | 0:679fb5e8a0b4 | 30 | } |
p4ken | 0:679fb5e8a0b4 | 31 | RCK = 0; |
p4ken | 0:679fb5e8a0b4 | 32 | RCK = 1; |
p4ken | 0:679fb5e8a0b4 | 33 | if(count==7) count=-1; |
p4ken | 0:679fb5e8a0b4 | 34 | count++; |
p4ken | 0:679fb5e8a0b4 | 35 | wait(0.2); |
p4ken | 0:679fb5e8a0b4 | 36 | } |
p4ken | 0:679fb5e8a0b4 | 37 | } |