Go Down

Topic: 6xmax7219 Wine Rack RGB LED Matrix  (Read 274 times) previous topic - next topic

rexys

Hi, I need a little help in what direction I should code this project,
probably more for web portion than to audrino part.


The idea:
Audrino + ethernet shield + 6 x MAX7219
Must show a lamp (LED) matrix (8x16) RGB
(1 RGB LED behind each of the 128 wine bottles)

And with a MySQL web database, for example all wines from the year 2007
and so only the wines from 2007 lights green, all other red etc.

It works fine if I'm in the database searches on a particular wine (1 bottle)
(Clear display then Rx/Cx = True=Light on wine)

But how do I send the entire array from web to audrino at once?

My own idea is to search the database of wines '2007' and sort them by location RAW / and then send the code to Ethernet Shield column after column .. as bytes .. but is there a better way ??

I use "LedControl.h"

Any help is welcome.

Kind Regards
Jan

Grumpy_Mike

Quote
Audrino + ethernet shield + 6 x MAX7219
Must show a lamp (LED) matrix (8x16) RGB
Stop right there.
You can't drive an RGB LED with three MAX7219s.

PaulRB

But you could have separate red and green leds at each location. You can use max7219 like that.

An alternative to consider might be ws2812 leds. RGB and no driver chips needed. Get the ones on tiny pcbs and daisy-chain them. Might even cost less overall!

Paul

Grumpy_Mike

#3
Feb 26, 2015, 12:22 pm Last Edit: Feb 26, 2015, 12:23 pm by Grumpy_Mike
You can only use a MAX7219 with an RGB LED if it is not a common anode or common cathode type, the only one I know is the surface mount 5050.

Quote
An alternative to consider might be ws2812 leds.
Well there is this:-
http://www.rapidonline.com/Electronic-Components/Pimoroni-Unicorn-HAT-8x8-RGB-LED-Matrix-for-Raspberry-Pi-Model-B-73-6042

Cheaper than you might think and hackable for an arduino.

This one is the AdaFruit offering and is more expensive:-
matrix

PaulRB

I was thinking of these, because Jan will need to locate one led behind each bottle.

Jan, you would need to change from using LedControl library to Neopixel or FastLED libraries, but they will be easier to use overall since you can set the colour of each led as a single command. Also you can choose from hundreds of colours, not just 7, and the wiring will be far, far simpler.

Paul


rexys

thanks for all the answers

Sorry I forgot to write it, but it is true they can not run with RGB leds ..

Therefore 6 max..

2xREDmax 2xGREENmax 2xBLUEmax

(separate LEDs)

PaulRB

#6
Feb 26, 2015, 06:02 pm Last Edit: Feb 26, 2015, 06:17 pm by PaulRB
Jan, how much hardware have you purchased so far? You should very seriously consider switching to ws2812. It will be worthwhile purely to make the wiring simple!

With max7219 you will need 6 wires to each wine bottle from the control circuit board(s) containing the chips. That is 768 wires. Plus wires between the Arduino, power supply and the control board(s) and between the control boards if you split the chips over multiple boards.

With ws2812 you have only 3 wires, daisy-chained from one led to the next in one long chain. These connect back to the Arduino & power supply and there are no extra shelds or boards needed.

Plus you can have cool effects like ranges of mixed colours to represent sweet/dry or age or whatever of the wines on offer. And the leds will be much brighter than with max7219 if you want but they can be individually dimmed.

Paul__B

#7
Feb 26, 2015, 10:25 pm Last Edit: Feb 26, 2015, 10:26 pm by Paul__B
You can only use a MAX7219 with an RGB LED if it is not a common anode or common cathode type,
Of course you clearly can use MAX7219s to drive either common anode or common cathode RGB LEDS.

The constraint is that you can only use two rows or two columns, as you only have six, not eight LED elements on a common, so you can drive only sixteen RGB LEDs per chip, for 128 LEDs you would require eight MAX7219s.

If you use common anode LEDs, you will be using a more efficient six-way multiplex.

rexys

Jan, how much hardware have you purchased so far? You should very seriously consider switching to ws2812. It will be worthwhile purely to make the wiring simple!

With max7219 you will need 6 wires to each wine bottle from the control circuit board(s) containing the chips. That is 768 wires. Plus wires between the Arduino, power supply and the control board(s) and between the control boards if you split the chips over multiple boards.

With ws2812 you have only 3 wires, daisy-chained from one led to the next in one long chain. These connect back to the Arduino & power supply and there are no extra shelds or boards needed.

Plus you can have cool effects like ranges of mixed colours to represent sweet/dry or age or whatever of the wines on offer. And the leds will be much brighter than with max7219 if you want but they can be individually dimmed.
I think that is the way to go...

Only bourght 4 Max7219 and a few leds..
Any help to program it ?

Kind Regards

PaulRB

#9
Mar 12, 2015, 03:24 pm Last Edit: Mar 12, 2015, 04:09 pm by PaulRB
Any help to program it ?
I can help you with the ws2812 side of the programming. I have less experience with the ethernet side, but I'm sure others here will make up for my deficiencies.

You could send 384 bytes to the Arduino each time something changes. That would be one byte for r, g & b for each led. The Arduino would then simply update the led string.

Alternatively, you could send 128 HTML-style hex colour values, e.g. "#33CC33"

rexys

Thanks... I just ordered 250 pcs WS2812B boards..

I will return then i recive them ;)

rexys

Now i got 250 pcs. WS2812B

Made a test Sketch Works fine:
Code: [Select]


#include <SPI.h>
#include <Ethernet.h>
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>

// NeoPixels Setup
#define PIN            6
#define NUMPIXELS      16
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// Ethernet setup
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };   //physical mac address
byte ip[] = { 192, 168, 1, 178 };                      // ip in lan (that's what you need to use in your browser. ("192.168.1.178")
byte gateway[] = { 192, 168, 1, 1 };                   // internet access via router
byte subnet[] = { 255, 255, 255, 0 };                  //subnet mask
EthernetServer server(80);                             //server port     
String readString;

int delayval = 500; // delay for half a second

void setup() {
 
  pixels.begin(); // This initializes the NeoPixel library.
 
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
      }

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip, gateway, subnet);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
 
 
}
void loop() {

   // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {   
      if (client.available()) {
        char c = client.read();
     
        //read char by char HTTP request
        if (readString.length() < 100) {
          //store characters to string
          readString += c;
          //Serial.print(c);
         }

         //if HTTP request has ended
         if (c == '\n') {         
           Serial.println(readString); //print to serial monitor for debuging
     
           client.println("HTTP/1.1 200 OK"); //send new page
           client.println("Content-Type: text/html");
           client.println();     
           client.println("<HTML>");
           client.println("<HEAD>");
           client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
           client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black-translucent' />");
           client.println("<link rel='stylesheet' type='text/css' href='http://randomnerdtutorials.com/ethernetcss.css' />");
           client.println("<TITLE>Random Nerd Tutorials Project</TITLE>");
           client.println("</HEAD>");
           client.println("<BODY>");
           client.println("<H1>Random Nerd Tutorials Project</H1>");
           client.println("<hr />");
           client.println("<br />"); 
           client.println("<H2>Arduino with Ethernet Shield</H2>");
           client.println("<br />"); 
           client.println("<a href=\"/?button1on\"\">Turn On GREEN LED</a>");
           client.println("<a href=\"/?button1off\"\">Turn Off GREEN LED</a><br />");   
           client.println("<br />");     
           client.println("<br />");
           client.println("<a href=\"/?button2on\"\">Turn On PURPLE LED</a>");
           client.println("<a href=\"/?button2off\"\">Turn PURPLE Off LED</a><br />");
           client.println("<p>Created by Rui Santos. Visit http://randomnerdtutorials.com for more projects!</p>"); 
           client.println("<br />");
           client.println("</BODY>");
           client.println("</HTML>");
     
           delay(1);
           //stopping client
           client.stop();
           int i = 0; //Index for WS2812
             //controls the Arduino if you press the buttons
           if (readString.indexOf("?button1on") >0){
            i=1;
            pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.
            pixels.show(); // This sends the updated pixel color to the hardware.
           }
           if (readString.indexOf("?button1off") >0){
            i=(1);
            pixels.setPixelColor(i, pixels.Color(0,0,0)); // Moderately bright green color.
            pixels.show(); // This sends the updated pixel color to the hardware.
           }
           if (readString.indexOf("?button2on") >0){
            i=(2);
            pixels.setPixelColor(i, pixels.Color(150,0,0)); // Moderately bright green color.
            pixels.show(); // This sends the updated pixel color to the hardware.
           }
           if (readString.indexOf("?button2off") >0){
            i=(2);
            pixels.setPixelColor(i, pixels.Color(0,0,0)); // Moderately bright green color.
            pixels.show(); // This sends the updated pixel color to the hardware.
           }
            //clearing string for next read
            readString=""; 
           
         }
       }
    }
}
}



Now for the problems...

My big problem is how I update several leds in the same line ...
Code: [Select]

 if (readString.indexOf("?button1on") >0){
            i=1;
            pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.
            pixels.show(); // This sends the updated pixel color to the hardware.
           }

Here I update one leds from http
(right now from a button on the side, but the same effect as from the database,
which just calls a unique Internet address)

But how do I in only one line update several leds ??

PaulRB

Well, you don't say which leds you want to update, so I'll assume you want to update all of them:

Code: [Select]
if (readString.indexOf("?button1on") >0){
            for (i=1; i<NUMPIXELS; i++)
                pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.
            pixels.show(); // This sends the updated pixel color to the hardware.
           }

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy