About MAX7221 / 7segment use

Hi guys.

I've read the page LedControl for Arduino about the MAX7221 and I have a few questions:

  • I want to display a decimal value from a sensor on a 4x7 segments display. Should I extract the hundreds, tens, units and so on of the value and display each of this digit in their respective place through setDigit function?
  • I would also need to display these digits mirrored (so you see them right in a mirror, 3 becomes E for instance). Is there a way to override the setDigit function to create some kind of custom sets instead of using setLed which is much slower?

Thanks for the tips!

  1. yes.
  2. I don't use any libraries, the MAX7219 only needs data sent to a few registers.
    Use No Decode Mode, define a fontArray of digits & mirrored digits, and send those to the MAX7219. It's pretty simple part to use if you bother to read the datasheet and use SPI.transfer to send it an address and data:
digitalWrite (ssPin, LOW);
SPI.transfer(registerNumber); // 1 to 8 for display data, 9 t0 15 for control registers (use in setup)
SPI.transfer(fontArray[numberToDisplay]);
digitalWrite (ssPin, HIGH);

When your code gets to the digit where the decimal is to be set use something like this
digit |= 0b10000000;
Crossroads is the expert, learn to use your own code and write to the 7221 registers.

CrossRoads:
I don't use any libraries, the MAX7219 only needs data sent to a few registers.

I heartily agree. I find having all your code where you can see it much more practical.

CrossRoads:
It's pretty simple part to use if you bother to read the datasheet and use SPI.transfer to send it an address and data:

Actually, I find it easier not to use SPI.transfer. Doesn't that restrict you to particular pins?

Doesn't that restrict you to particular pins?

Yes - the fast hardware-supported IO pins.
So you can achieve fast 8 MHz comm's to the MAX7219, and not some dawdling software bit-bang speed. Blast out the data, let the program move on.

Thank you guys, the datasheet clarifies a lot indeed.

@CrossRoads: I found this example using a custom font array, but doesn't seem to be for Arduino.
ee.cleversoul.com/max7219-source.html
I may be able to adapt it, not without mind twists as I am really a beginner. Would you have by chance any code example for Arduino?

byte fontArray[] = {
0b00111111l, // 0, 1 = segment on
0b000000110, // 1
etc
};
0bDP-g-f-e-d-c-b-a
a
f b
g
e c
d DP

check the bits, should be total of 8 1s and 0s in each one.

See also reply 1: