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:
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.
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);
}
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.
No comments:
Post a Comment