Shahariar Hossain
/
FRDM-K82F_8x8LED_Matrix_nochip
Quick demo for LED 8x8 Matrix with FRDM-K82F
main.cpp
- Committer:
- suntopbd
- Date:
- 2018-05-23
- Revision:
- 1:1088a4658fc2
- Parent:
- 0:b16b3c2d882e
- Child:
- 2:4e21ea1275a1
File content as of revision 1:1088a4658fc2:
// copyleft by suntopbd 23.5.18 /* PINOUT https://os.mbed.com/platforms/FRDM-K82F/#board-pinout should work with any other board with 16 I/O available C1 C2 C3 C4 C5 C6 C7 C8 R1 x x x x x x x x R2 x x x x x x x x R3 x x x x x x x x R4 x x x x x x x x R5 x x x x x x x x R6 x x x x x x x x R7 x x x x x x x x R8 x x x x x x x x */ #include "mbed.h" // Row Pins // DigitalOut R1(PTC9); DigitalOut R2(PTC8); DigitalOut R3(PTC10); DigitalOut R4(PTC11); DigitalOut R5(PTA14); DigitalOut R6(PTC7); DigitalOut R7(PTA16); DigitalOut R8(PTA15); // Col Pins // DigitalOut C1(PTD0); DigitalOut C2(PTC12); DigitalOut C3(PTB17); DigitalOut C4(PTB16); DigitalOut C5(PTA5); DigitalOut C6(PTA13); DigitalOut C7(PTA12); DigitalOut C8(PTA17); // func declearation // void disp_off(void); void disp_line(int,int,int,int,int,int,int,int,int); void disp_page(int*); int *dotpointer; // 0 will glow LED and 1 will keep off // // Use it to make Icon, Character, Symble // int canvas[64] = { 1,1,1,0,0,1,1,1, 1,1,0,0,0,0,1,1, 1,0,0,0,0,0,0,1, 0,0,0,0,0,0,0,0, 1,1,0,0,0,0,1,1, 1,1,0,0,0,0,1,1, 1,1,0,0,0,0,1,1, 1,1,0,0,0,0,1,1, }; int m[64] = { 1,1,1,1,1,1,1,1, 0,0,1,1,1,0,0,1, 0,1,0,1,0,1,0,1, 0,1,1,0,1,1,0,1, 0,1,1,1,1,1,0,1, 0,1,1,1,1,1,0,1, 0,1,1,1,1,1,0,1, 0,1,1,1,1,1,0,1, }; int b[64] = { 1,1,1,1,1,1,1,1, 0,0,0,0,0,1,1,1, 0,1,1,1,1,0,1,1, 0,1,1,1,1,0,1,1, 0,0,0,0,0,1,1,1, 0,1,1,1,1,0,1,1, 0,1,1,1,1,0,1,1, 0,0,0,0,0,1,1,1, }; int e[64] = { 1,1,1,1,1,1,1,1, 0,0,0,0,0,0,1,1, 0,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1, 0,0,0,0,0,1,1,1, 0,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1, 0,0,0,0,0,0,1,1, }; int d[64] = { 1,1,1,1,1,1,1,1, 0,0,0,0,1,1,1,1, 0,1,1,1,0,1,1,1, 0,1,1,1,1,0,1,1, 0,1,1,1,1,0,1,1, 0,1,1,1,1,0,1,1, 0,1,1,1,0,1,1,1, 0,0,0,0,1,1,1,1, }; int space[64] = { 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, }; void update_disp_m(); void update_disp_b(); void update_disp_e(); void update_disp_d(); void update_disp_space(); Timer timer; int main() { // SETUP // disp_off(); timer.start(); // END OF SETUP // // LOOP // while (1) { while (timer.read() < 0.6) {update_disp_m();}timer.reset(); while (timer.read() < 0.6) {update_disp_b();}timer.reset(); while (timer.read() < 0.6) {update_disp_e();}timer.reset(); while (timer.read() < 0.6) {update_disp_d();}timer.reset(); while (timer.read() < 0.8) {update_disp_space();}timer.reset(); } // END OF LOOP // } //..........................................// // MBED OS Tasks // void update_disp_m() { dotpointer = &m[0]; disp_page(dotpointer); disp_off(); } void update_disp_b() { dotpointer = &b[0]; disp_page(dotpointer); disp_off(); } void update_disp_e() { dotpointer = &e[0]; disp_page(dotpointer); disp_off(); } void update_disp_d() { dotpointer = &d[0]; disp_page(dotpointer); disp_off(); } void update_disp_space() { dotpointer = &space[0]; disp_page(dotpointer); disp_off(); } // End of Tasks // // Functions Body // void disp_off(void) { // for CC type C1 = 1; C2 = 1; C3 = 1; C4 = 1; C5 = 1; C6 = 1; C7 = 1; C8 = 1; // for CA //C1 = 0; C2 = 0; C3 = 0; C4 = 0; C5 = 0; C6 = 0; C7 = 0; C8 = 0; } void disp_line(int r,int c1,int c2,int c3,int c4,int c5,int c6,int c7,int c8) { disp_off(); if(r==1) {R1=1;R2=0;R3=0;R4=0;R5=0;R6=0;R7=0;R8=0;} if(r==2) {R1=0;R2=1;R3=0;R4=0;R5=0;R6=0;R7=0;R8=0;} if(r==3) {R1=0;R2=0;R3=1;R4=0;R5=0;R6=0;R7=0;R8=0;} if(r==4) {R1=0;R2=0;R3=0;R4=1;R5=0;R6=0;R7=0;R8=0;} if(r==5) {R1=0;R2=0;R3=0;R4=0;R5=1;R6=0;R7=0;R8=0;} if(r==6) {R1=0;R2=0;R3=0;R4=0;R5=0;R6=1;R7=0;R8=0;} if(r==7) {R1=0;R2=0;R3=0;R4=0;R5=0;R6=0;R7=1;R8=0;} if(r==8) {R1=0;R2=0;R3=0;R4=0;R5=0;R6=0;R7=0;R8=1;} C1=c1;C2=c2;C3=c3;C4=c4; C5=c5;C6=c6;C7=c7;C8=c8; } void disp_page(int *dot) { disp_line(1,*(dot+0) ,*(dot+1) ,*(dot+2) ,*(dot+3) ,*(dot+4) ,*(dot+5) ,*(dot+6) ,*(dot+7) ); disp_line(2,*(dot+8) ,*(dot+9) ,*(dot+10),*(dot+11),*(dot+12),*(dot+13),*(dot+14),*(dot+15)); disp_line(3,*(dot+16),*(dot+17),*(dot+18),*(dot+19),*(dot+20),*(dot+21),*(dot+22),*(dot+23)); disp_line(4,*(dot+24),*(dot+25),*(dot+26),*(dot+27),*(dot+28),*(dot+29),*(dot+30),*(dot+31)); disp_line(5,*(dot+32),*(dot+33),*(dot+34),*(dot+35),*(dot+36),*(dot+37),*(dot+38),*(dot+39)); disp_line(6,*(dot+40),*(dot+41),*(dot+42),*(dot+43),*(dot+44),*(dot+45),*(dot+46),*(dot+47)); disp_line(7,*(dot+48),*(dot+49),*(dot+50),*(dot+51),*(dot+52),*(dot+53),*(dot+54),*(dot+55)); disp_line(8,*(dot+56),*(dot+57),*(dot+58),*(dot+59),*(dot+60),*(dot+61),*(dot+62),*(dot+63)); } // End of Functions //