10 years, 11 months ago.

How can i drive an MAX7219 or 7221

Hello, How can I drive an MAX7219 or MAX 7221

1 Answer

10 years, 9 months ago.

  1. include "mbed.h"

const char sprite[8] = { 0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xFF };

SPI spimax(SPI_MOSI, SPI_MISO, SPI_SCK); DigitalOut CS(PB_6);

void max7219(char reg,char dta) { CS = 0; spimax.write(reg); spimax.write(dta); CS = 1; }

int main() { max7219(0x09,0); max7219(0x0a,8); max7219(0x0b,7); max7219(0x0c,1); max7219(0x0f,0);

for(char j=0;j<8;j++) { max7219(j+1,sprite[j]); }

while(1) { } }