Arduino ethernet shidel with DMD 2 library.

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
sarmadhassan
Posts:1
Joined:Tue Nov 22, 2016 3:20 pm
Arduino ethernet shidel with DMD 2 library.

Post by sarmadhassan » Tue Nov 22, 2016 3:30 pm

Has anyone interfaced dmd and ethernet shield with arduino mega using DMD 2 library. ? I have successfully interfaced these two individually with arduino mega but after merrging both codes together, i am getting garbage on the screen. Any help or suggestion ? Below is my code attached...

Code: Select all


#include <SPI.h>
#include <Ethernet.h>
#include <DMD2.h>
#include <fonts/SystemFont5x7.h>
#include <fonts/Arial14.h>

// Set Width to the number of displays wide you have
//const int WIDTH = 1;
 
// You can change to a smaller font (two lines) by commenting this line,
// and uncommenting the line after it:
const uint8_t *FONT = Arial14;
//const uint8_t *FONT = SystemFont5x7;

const char *MESSAGE = " Hello World ";
SoftDMD dmd(2,1,9,6,7,8,52,51);
DMD_TextBox box(dmd);  // "box" provides a text box to automatically write to/scroll the display

byte mac[] = {  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02};
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "projects.flowingdata.com";    // name address for Google (using DNS)
EthernetClient client; 

// the setup routine runs once when you press reset:
void setup() {
  Serial.begin(9600);
    dmd.setBrightness(255);
  dmd.selectFont(FONT);
  dmd.begin();
  // start the Ethernet connection:
  if (Ethernet.begin(mac) != 0) 
  { Serial.println("Failed to configure Ethernet using DHCP");    for (;;)       ;   }
  // print your local IP address:
  printIPAddress();

  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /holidays/current-rates.txt HTTP/1.0");
    client.println("Host: projects.flowingdata.com");
    client.println("Connection: close");
    client.println();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
  
}

// the loop routine runs over and over again forever:
void loop() {
// if there are incoming bytes available  // from the server, read them and print them:
  if (client.available())
  {
    char c = client.read();
    Serial.print(c);
  }

  // if the server's disconnected, stop the client:
  if (!client.connected())
  {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while (true);
  }
  
  const char *next = MESSAGE;
  while(*next) {
    Serial.print(*next);
    box.print(*next);
    delay(200);
    next++;
  }
}

void printIPAddress()
{
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print(".");
  }
  Serial.println();
}

Post Reply