Arduino Uno to Maxim7219

Hello Arduino forum,

Working on using the Arduino Uno and Maxim 7219
to control three hundred LEDs.

Using the schematics and LEDControl library from
http://playground.arduino.cc/Main/MAX72XXHardware

Hooked up a 7219 to 64 LEDs got anomalous result.

So broke it down to three LEDs as shown in this schematic

This would operate the first LED turing it on and off
but does nothing to the second and third LEDs.

A friend who has some electronics engineering
experience said a different sketch should be used
because
‘The built in arduino library doesnt like that chip the one
they provide…the reason it doesnt work is the Uno and the Max have different clock speeds.
I’m sure if you tinker with the library you can find where to divide the clock speed inside it.
The arduino library was written for the previous version of the arduino’

The sketch provided by the friend is copied herewith below as sketch two.
Problem is I have studied it and do not understand it.
For instance, it sort of indidcates that the DataIn, Clock
and Load pins are 11, 12, and 13 on the Arduino but
there is no indication of which is which. (Found the SPI.h
file in the libraries folder to fibgure out the Arduino pins
but it is even more cryptic than the sketch.)

Have studied a dozen different articles on Arduino to Maxim7219. Examples:

http://www.planetarduino.org/?cat=435

http://www.gammon.com.au/forum/?id=11516

Most of these use the LEDControl library and are on how
to use the 7219 to do scrolling matrices and/or seven segment
displays.

Question: Can anyone provide a simple sketch to turn on and then off
the first three LEDs as shown in the schematic?

Willing to remit $100 to first person able provide a simple,
working sketch.

Thanks.

Allen in Dallas

++++++++++++++++ begin Sketch 1+++++++++++++++++

#include “LedControl.h”

LedControl lc=LedControl(12,11,10,1);

unsigned long delaytime=500;

void setup() {

lc.shutdown(0,false);
/* Set the brightness to a medium values /
lc.setIntensity(0,8);
/
and clear the display */
lc.clearDisplay(0);
}

void loop() {

lc.setLed(0,0,0,true);
delay(delaytime);
lc.setLed(0,0,2,true);
delay(delaytime);
lc.setLed(0,0,3,true);
delay(delaytime);
lc.setLed(0,0,0,false);
delay(delaytime);
lc.setLed(0,0,2,false);
delay(delaytime);
lc.setLed(0,0,3,false);
delay(delaytime);
}

++++++++++++++++ end Sketch 1+++++++++++++++++

++++++++++++++++ begin Sketch 2+++++++++++++++++
/* program to put message on a MAX7219s.
Set up in No Decode mode.
*/
// ************************************ //
//a_presetup
#include <SPI.h>

// define pins usage
// D11-12-13 SPI interface

byte ss0 = 10;
byte x;
// define variables
// bytes to send to MAX7219s, with some initial data
byte displayArray = {
0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa}; //16 bytes

// define 7219 register addresses for setup
byte decode_mode = 0x09; // 0x00 = No decode for digits 7-0
byte intensity_level = 0x0A; // 0x08 = mid level. Range is 0x00 to 0x0F
byte scan_limit = 0x0B; // 0x07 for all columns
byte shutdown_normal = 0x0C; // 0x00 - shutdown, 0x01 = normal
byte display_test = 0x0F; // 0x00 = normal, 0x01 = display test mode all on full

// ************************************ //

// b_setup
void setup(){

pinMode (ss0, OUTPUT);
digitalWrite (ss0, HIGH);

Serial.begin(38400);

// turn on SPI port
SPI.begin();

/* set up MAX7219 registers */

// decode to No decode mode
digitalWrite (ss0, LOW);
SPI.transfer (decode_mode);
SPI.transfer (0x00);
digitalWrite (ss0, HIGH);

Serial.println(“No decode mode”);

// intensity to mid level
digitalWrite (ss0, LOW);
SPI.transfer (intensity_level);
SPI.transfer (0x0F);
digitalWrite (ss0, HIGH);

Serial.println(“Intensity”);

// scan limit to all 7 columns
digitalWrite (ss0, LOW);
SPI.transfer (scan_limit);
SPI.transfer (0x07);
digitalWrite (ss0, HIGH);

Serial.println(“Scan Limit”);

// dispay test On
digitalWrite (ss0, LOW);
SPI.transfer (display_test);
SPI.transfer (0x01);
digitalWrite (ss0, HIGH);
delay(2000);

Serial.println(“Display test on”);

// dispay test to normal
digitalWrite (ss0, LOW);
SPI.transfer (display_test);
SPI.transfer (0x00);
digitalWrite (ss0, HIGH);
delay(200);

Serial.println(“Display test off”);

// shutdown to Normal mode
digitalWrite (ss0, LOW);
SPI.transfer (shutdown_normal);
SPI.transfer (0x01);
digitalWrite (ss0, HIGH);

Serial.println(“Normal mode”);

delay(250);

Serial.println(“setup done”);

}
// ************************************ //

// c_loop
void loop(){

// ************************************ //
Serial.println("slaveSelect0 low "); // put data in registers 1 to 9. 16 bit transfer - address/data
for (x = 1; x<9; x=x+1){
digitalWrite (ss0, LOW);
SPI.transfer (x);
SPI.transfer(displayArray[x-1]);// array 0 to 7
digitalWrite (ss0, HIGH);
}

delay(1000);

Serial.println(“slaveSelect0 high”);

for (x = 1; x<9; x=x+1){
digitalWrite (ss0, LOW);
SPI.transfer (x);
SPI.transfer(displayArray[x+7]); // array 8 t0 15
digitalWrite (ss0, HIGH);
}

delay(1000);

} // end loop

++++++++++++++++++end sketch 2++++++++++++++++++++++

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :slight_smile:

Hi,
Have you tried this connection setup?

from here;

Tom... :slight_smile:

Hello Tom,

Thanks for your reply.

The connection setup is referenced in the original post and comes from
http://www.planetarduino.org/?cat=435

More importantly the setup is for running an LED Matrix

Also the Col/Row schematic shows the LED at Row1.Col1 is connected to 7219 pins 1 and 5. Pin 1 on the Maxm7219 is to DIN (digital in). How can this be connected to an LED turn it on and off?

Again this setup is for and LED matrix not a linear display.

Thanks again.

Allen

Hi,
Try this LED connection change, it should give you LED control of Row1 and Col 1 ,2 and 3


Tom... :slight_smile:
(I'm off to bed..)

Hi,
Make sure you have the LED matrix plugged in the right way around.

Tom… :slight_smile:

Hi, again
On my assemblies where I have put a red rrow, there is an extra nodule, like the ones on each corner of the array.
That is how mine is oriented.
MAX7219_LED_matrix_modules1ee.jpg

Tom.. :slight_smile:

MAX7219_LED_matrix_modules1ee.jpg

Hi,

Also the Col/Row schematic shows the LED at Row1.Col1 is connected to 7219 pins 1 and 5. Pin 1 on the Maxm7219 is to DIN (digital in). How can this be connected to an LED turn it on and off?

No, thats pin 1 and 5 on the LED matrix, they go to pins 23 and 17 of the IC.

Hi.
The first sketch you listed works for me.

#include "LedControl.h"

LedControl lc=LedControl(12,11,10,1);

unsigned long delaytime=500;

void setup() {

lc.shutdown(0,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,8);
/* and clear the display */
lc.clearDisplay(0);
}

void loop() {
  
 lc.setLed(0,0,0,true);
    delay(delaytime);
  lc.setLed(0,0,2,true);
    delay(delaytime);  
  lc.setLed(0,0,3,true);
    delay(delaytime);    
 lc.setLed(0,0,0,false);
    delay(delaytime);
  lc.setLed(0,0,2,false);
    delay(delaytime);  
 lc.setLed(0,0,3,false);
    delay(delaytime);   
}

I plugged the LED array in the otherway around and got many rows and columns lighting up but no animation.

Tom.. :slight_smile:

Hello Tom and Arduino forum,

Found mistake in the sketch.
I listed 0,0,0 0,0,2, 0,0,3
Should be 0,0,0 0,0,1, 0,0,2

Corrected and recopied below.

Tried the hookup pictured in
MAX72XX_SPI_170909edit.jpg

Result: Nothing. No LEDs light up.
for either the old or the corrected sketch.

Perhaps the wrong idea has been captured.
I am not trying to hook up a matrix.
There was an entry about hooking up the matrix
backwards.

There is no matrix.

I am trying to hook up three individual LEDs
to the first three connections of the 7219.

If this schematic is perused

it can be seen that for the first LED marked '0.0'
the first anode goes to Seg DP (pin 22)
and
the cathode goes to DIG 2 (pin)

The excellent schematic
MAX72XX_SPI_170909edit.jpg
says that for the first LED marked '0.0'
the first anode goes to Seg D (pin 23)
and
the cathode goes to Seg G (pin 17)

I am curious about where that hookup was obtained.

If the breadboard is hooked according to
'Arduino to Max7219 Linear displayed, Simplified'
the first LED, marked 0.0 turns on and off
as expected, but the second and third, 0.1 and
0.2 do nothing.

And the DelayTime and can be altered and the
the duty time of LED 0.0 reacts as expected.

So I can get the sketch to work the first LED
but not the second and third.
Perhaps, it is, has Tom postulates, the hookup.
But I suspect it is the sketch although I am not sure.

Still stumped.

Thanks.

Allen

#include "LedControl.h"

LedControl lc=LedControl(12,11,10,1);

unsigned long delaytime=200;

void setup() {

lc.shutdown(0,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,8);
/* and clear the display */
lc.clearDisplay(0);
}

void loop() {
  
 lc.setLed(0,0,0,true);
    delay(delaytime);
  lc.setLed(0,0,1,true);
    delay(delaytime);  
  lc.setLed(0,0,2,true);
    delay(delaytime);    
 lc.setLed(0,0,0,false);
    delay(delaytime);
 lc.setLed(0,0,1,false);
    delay(delaytime);  
 lc.setLed(0,0,2,false);
    delay(delaytime);   
}

Hi,
Check that you are not on 1,0 instead of 0,1?
Just change the code.

Try

Tom... :slight_smile: