Showing posts with label MAX7219. Show all posts
Showing posts with label MAX7219. Show all posts

Tuesday, 3 June 2014

MAX7219 – Experimentation – Driving 2 LED

After receiving my delivery of MAX7219-ENG chips from eBay, I’ve been struggling to understand how to use this useful chip. Most of the information that I’ve found on the Internet shows how to connect the chip to an 8x8 dot matrix display, which is great … but … I can buy the dot matrix display with a driver board (including the MAX7219 chip), so why would I want to?
Maybe my intended use of the chip is a bit wrong … but, whatever. It will probably do what I want it to do.
The goal with this bit of experimentation is to connect the MAX7219-ENG to two LED and to write a simple Arduino sketch to run the MAX7219.
What I came up with is as follows:
2LED Driven by MAX7219 with Arduino UNO_bb
The Arduino is connected to the MAX via pin 9 (data), 10 (clock) and 11 (latch). I’ve also got 5V and Ground from the Arduino connected to the breadboard.
Pins 4 and 9 of the MAX connect to Ground.
Pin 19 connects to the 5V rail directly and pin 18 connects to the 5V rail via a 10kΩ resistor.
The two LED connect to the Digit drivers and Segment drivers.
Green LED connects to D0 (pin 2 of the MAX) to the cathode and SEG DP (pin 22 of the MAX) to the anode. The blue LED connects to D1 (pin 11 of the MAX) to the cathode and SEG A (pin 14 of the MAX) to its anode.
That’s pretty much all there is to it. Adding LED is a matter of Digit driver pin to cathode, Segment driver to anode. But that means we are really only driving a maximum of 8 LED per MAX7219. It would make more sense to build the LED into an array, but for this experiment, that’s what I want.
View1View2View3
The above images show the Arduino Uno connected to the MAX7219 and 2 LEDS. I’ve taken shots from different views so that you can see how the project relates to the breadboard schematic above.
The sketch is pretty straight forward. Just remember that there is no array of LED to control, so we’re only interested in 0 and 1.
#include <ledcontrolms.h>
LedControl lc = LedControl(9, 10, 11, 0);

void setup()
{
Serial.begin(9600);
lc.shutdown(0, false);
lc.setIntensity(0, 8);
lc.clearDisplay(0);
}

void loop ()
{

for(int i = 0; i < 16; i++)
{
lc.setLed(0, 1, 1, false);
lc.setIntensity(0, i);
lc.setLed(0, 0, 0, true);
delay(30);
}
delay(1000);
for(int i = 15; i > 0; i--)
{
lc.setLed(0, 1, 1, true);
lc.setIntensity(0, i);
lc.setLed(0, 0, 0, true);
delay(30);
}

delay(120);
}

And, here’s the project running…

ARDUINO and MAX7219 controlling two LED

The sketch doesn’t do quite what I want it to do, but for the sake of the experiment … it works.

What I wanted it to do was for the green LED to cycle low to high and then the blue LED to cycle, kinda a glow and fade oscillation. I’m OK with it, I will spend some more time working out what I did wrong with the sketch sometime later.

Wednesday, 7 May 2014

MAX7219 and the Arduino

I received my 8x8 LED Matrix with the MAXIM7219 chip that I bought on eBay.
Picture 40
and then I proceeded to try and get it up and running with the Arduino UNO that I have.
A quick search on the Internet didn’t really help me very much, at first. But then I found an Instructable that was actually useful, it makes use of the MakeSpace LEDControl library (LedControlMS.h). There were some other little gotchas along the way too. Like, how the hell do you install a user contributed library into the Arduino IDE? Fortunately, there is a guide on libraries on the Arduino website, so I was able to get the library and install it.
The library comes with an example sketch, so I used that as a starting point and started to scratch around in the code to see what I could do.
Picture 41
The example contains three very useful lines of comment:
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD
Apart from that, you connect GND on the board to GND on the Arduino and VCC on the board to 5V on the Arduino, compile and load and you are away!
The LED Matrix running after a little tinkering with the sketch.
The upshot is, the use of an LED Display Matrix is very easy. If I need to have a display happening on any of my electronic projects, I know what I’m going to use.
Also, I’ve had a look around the Internet for DIY LED Display Matrixes, and there are some projects out there that I might very well undertake for myself and see how far I can push it. One or two projects out there using tri-colour LED, they look pretty cool.

Paypal Donations

Donations to help me to keep up the lunacy are greatly appreciated, but NOT mandatory.