test aff8x8 avec 2*74HC595 (KRM2388AURPGB)
Fork of DigitalIn_test by
main.cpp
- Committer:
- ER4
- Date:
- 2015-03-09
- Revision:
- 2:a0e8e160bed1
- Parent:
- 1:5a049a86616a
- Child:
- 3:555b0f6dd516
File content as of revision 2:a0e8e160bed1:
#include "mbed.h" SPI spi(P0_9,P0_8,P0_7); // mosi, miso, sclk DigitalOut cs(P0_6); void ligne(char val){ cs = 0; //spi.write(val); spi.write(0xFF); cs = 1; } //void colone(char val1){ // cs=0; //spi.write(val1); //cs=1; //} char Im [8][8] = { {0,0,0,0,0,0,0,0}, {0,0,1,0,1,0,0,0}, {0,0,1,0,1,0,0,0}, {0,0,1,0,1,0,0,0}, {1,0,0,0,0,0,0,1}, {0,1,1,1,1,1,1,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}}; int main() { int i=0,j=0; // Chip must be deselected cs = 1; // Setup the spi for 8 bit data, high steady state clock, // second edge capture, with a 1MHz clock rate spi.format(8,3); spi.frequency(1000000); while(1){ for(i=0;i<8;i++){ for (j=0;j<=7;j++){ //spi.write(colone[j]); cs = 0; if(Im[i][j]==1) spi.write(~(1<<j));//allume pixel else spi.write(0xFF); //eteind pixel spi.write(1<<i);//lignes //spi.write(0xFF); cs = 1; } } wait(0.001); } }