Problem making LED dot matrix work

hi there,

quick info:

I am making a spectrum analyzer project for my school and I have started learning c programming and frankly not really good at it. I am making a spectrum analyzer using an arduino uno + spectrum shield (from sparkfun) + 16x32 LED dot matrix (from sure electronics).

I got a program code from John Boxall from tronixstuff.com. However, the led matrix that he used is different to what I am using. I have looked at pin connection that was stated in the DMD.h and followed it but no luck. Can you guys help me out in making project work.

This is the code that I'm using:

// Example 48.2 - tronixstuff.com/tutorials > chapter 48 - 30 Jan 2013 
// MSGEQ7 spectrum analyser shield and I2C LCD from akafugu
// for akafugu I2C LCD
#include "Wire.h"
#include "TWILiquidCrystal.h"
LiquidCrystal lcd(50);
// create custom characters for LCD
byte level0[8] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b11111};
byte level1[8] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b11111, 0b11111};
byte level2[8] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b11111, 0b11111, 0b11111};
byte level3[8] = { 0b00000, 0b00000, 0b00000, 0b00000, 0b11111, 0b11111, 0b11111, 0b11111};
byte level4[8] = { 0b00000, 0b00000, 0b00000, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
byte level5[8] = { 0b00000, 0b00000, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
byte level6[8] = { 0b00000, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
byte level7[8] = { 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111, 0b11111};
int strobe = 4; // strobe pins on digital 4
int res = 5; // reset pins on digital 5
int left[7]; // store band values in these arrays
int right[7];
int band;
void setup()
{
 Serial.begin(9600);
 // setup LCD and custom characters
 lcd.begin(16, 2);
 lcd.setContrast(24);
 lcd.clear();
lcd.createChar(0,level0);
 lcd.createChar(1,level1);
 lcd.createChar(2,level2);
 lcd.createChar(3,level3);
 lcd.createChar(4,level4);
 lcd.createChar(5,level5);
 lcd.createChar(6,level6);
 lcd.createChar(7,level7);
 lcd.setCursor(0,1);
 lcd.print("Left");
 lcd.setCursor(11,1);
 lcd.print("Right");
 pinMode(res, OUTPUT); // reset
 pinMode(strobe, OUTPUT); // strobe
 digitalWrite(res,LOW); // reset low
 digitalWrite(strobe,HIGH); //pin 5 is RESET on the shield
}
void readMSGEQ7()
// Function to read 7 band equalizers
{
 digitalWrite(res, HIGH);
 digitalWrite(res, LOW);
 for( band = 0; band < 7; band++ )
 {
 digitalWrite(strobe,LOW); // strobe pin on the shield - kicks the IC up to the next band 
 delayMicroseconds(30); // 
 left[band] = analogRead(0); // store left band reading
 right[band] = analogRead(1); // ... and the right
 digitalWrite(strobe,HIGH); 
 }
}
void loop()
{
 readMSGEQ7();
// display values of left channel on LCD
 for( band = 0; band < 7; band++ )
 {
 lcd.setCursor(band,0);
 if (left[band]>=895) { lcd.write(7); } else
 if (left[band]>=767) { lcd.write(6); } else
 if (left[band]>=639) { lcd.write(5); } else
 if (left[band]>=511) { lcd.write(4); } else
 if (left[band]>=383) { lcd.write(3); } else
 if (left[band]>=255) { lcd.write(2); } else
 if (left[band]>=127) { lcd.write(1); } else
 if (left[band]>=0) { lcd.write(0); }
 }
 // display values of right channel on LCD
 for( band = 0; band < 7; band++ )
 {
 lcd.setCursor(band+9,0);
 if (right[band]>=895) { lcd.write(7); } else
 if (right[band]>=767) { lcd.write(6); } else
 if (right[band]>=639) { lcd.write(5); } else
 if (right[band]>=511) { lcd.write(4); } else
 if (right[band]>=383) { lcd.write(3); } else
 if (right[band]>=255) { lcd.write(2); } else
 if (right[band]>=127) { lcd.write(1); } else
 if (right[band]>=0) { lcd.write(0); }
 }
}

I have attached the lib that I'm using.

This is the website the I got my info from
http://tronixstuff.com/2013/01/31/tutorial-arduino-and-the-msgeq7-spectrum-analyzer/

P.S. Thanks to John Boxall for his tutorial and write up on the spectrum shield.

cheers,

DMD-master.zip (20.7 KB)

It almost sounds like you are asking us to change an apple into an orange.

I am making a spectrum analyzer project for my school and I have started learning c programming and frankly not really good at it. I am making a spectrum analyzer

You are either naive or very ambitious. If your problem is that the LED matrix is not the same as the one used by the person whose project you want to copy, (you can call it build, but as you described it , it sounds more like copy since all of the R&D has been done by someone else. If you expect us to address the issue (the incompatibility of the led matrix, you might want to start by providing us with some documentation for it) You need to tell us why or how yours is different from Johns. Looking at his is not going to help because you don't have that. So if you read the tutorial, what can you tell us about the code ? What is it your are asking us to do ? You haven't asked any questions yet. What is your question ?

Oh your right, I`m sorry about that..

Well, right now I'm trying to copy what John has done with his build and see if I can make it work.

Sorry, I just realized that I posted the wrong code. Here's the one that I'm trying out:

// Example 48.3 - tronixstuff.com/tutorials > chapter 48 - 30 Jan 2013 
// MSGEQ7 spectrum analyser shield with a Freetronics DMD
// for DMD
#include "DMD.h" // for DMD
#include "SPI.h" // SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include "TimerOne.h"
#include "SystemFont5x7.h" // keep next two lines if you want to add some text
#include "Arial_black_16.h"
DMD dmd(1, 1); // creates instance of DMD to refer to in sketch
void ScanDMD() // necessary interrupt handler for refresh scanning of DMD
{ 
 dmd.scanDisplayBySPI();
}
int strobe = 4; // strobe pins on digital 4
int res = 5; // reset pins on digital 5
int left[7]; // store band values in these arrays
int right[7];
int band;
void setup()
{
 // for DMD
 //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
 Timer1.initialize( 5000 ); //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
 Timer1.attachInterrupt( ScanDMD ); //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI() 
 dmd.clearScreen( true ); //true is normal (all pixels off), false is negative (all pixels on)

 // for MSGEQ7
 pinMode(res, OUTPUT); // reset
 pinMode(strobe, OUTPUT); // strobe
 digitalWrite(res,LOW); // reset low
 digitalWrite(strobe,HIGH); //pin 5 is RESET on the shield
}
void readMSGEQ7()
// Function to read 7 band equalizers
{
 digitalWrite(res, HIGH);
 digitalWrite(res, LOW);
 for( band = 0; band < 7; band++ )
 {
 digitalWrite(strobe,LOW); // strobe pin on the shield - kicks the IC up to the next band 
 delayMicroseconds(30); // 
 left[band] = analogRead(0); // store left band reading
 right[band] = analogRead(1); // ... and the right
 digitalWrite(strobe,HIGH); 
 }
}
void loop()
{
 int xpos;
 readMSGEQ7();
 dmd.clearScreen( true ); 
 // display values of left channel on DMD
 for( band = 0; band < 7; band++ )
 {
 xpos = (band*2)+1;
 if (left[band]>=895) { dmd.drawLine( xpos, 15, xpos, 1, GRAPHICS_NORMAL ); } else
 if (left[band]>=767) { dmd.drawLine( xpos, 15, xpos, 3, GRAPHICS_NORMAL ); } else
 if (left[band]>=639) { dmd.drawLine( xpos, 15, xpos, 5, GRAPHICS_NORMAL ); } else
 if (left[band]>=511) { dmd.drawLine( xpos, 15, xpos, 7, GRAPHICS_NORMAL ); } else
 if (left[band]>=383) { dmd.drawLine( xpos, 15, xpos, 9, GRAPHICS_NORMAL ); } else
 if (left[band]>=255) { dmd.drawLine( xpos, 15, xpos, 11, GRAPHICS_NORMAL ); } else
 if (left[band]>=127) { dmd.drawLine( xpos, 15, xpos, 13, GRAPHICS_NORMAL ); } else
 if (left[band]>=0) { dmd.drawLine( xpos, 15, xpos, 15, GRAPHICS_NORMAL ); }
 }

 // display values of right channel on DMD
 for( band = 0; band < 7; band++ )
 {
 xpos = (band*2)+18;
 if (right[band]>=895) { dmd.drawLine( xpos, 15, xpos, 1, GRAPHICS_NORMAL ); } else
 if (right[band]>=767) { dmd.drawLine( xpos, 15, xpos, 3, GRAPHICS_NORMAL ); } else
 if (right[band]>=639) { dmd.drawLine( xpos, 15, xpos, 5, GRAPHICS_NORMAL ); } else
 if (right[band]>=511) { dmd.drawLine( xpos, 15, xpos, 7, GRAPHICS_NORMAL ); } else
 if (right[band]>=383) { dmd.drawLine( xpos, 15, xpos, 9, GRAPHICS_NORMAL ); } else
 if (right[band]>=255) { dmd.drawLine( xpos, 15, xpos, 11, GRAPHICS_NORMAL ); } else
 if (right[band]>=127) { dmd.drawLine( xpos, 15, xpos, 13, GRAPHICS_NORMAL ); } else
 if (right[band]>=0) { dmd.drawLine( xpos, 15, xpos, 15, GRAPHICS_NORMAL ); }
 }
}

From the tutorial:
the spectrum shield takes an audio and then splits it into seven frequency points. The peaks of the seven points are then returned as DC which is read by the arduino.

From the code I believe that:

  • The spectrum shield takes the seven peaks and stores it into an array (left[band] and right[band]).
  • It is then displayed on the LED matrix in the void loop calling the array.

My problem is trying to take these readings that are stored in the array and show it on the LED matrix.

So what I did was checked the pin assignment in the DMD.h and it is stated as:

#warning CHANGE THESE TO SEMI-ADJUSTABLE PIN DEFS!
//Arduino pins used for the display connection
#define PIN_DMD_nOE 9 // D9 active low Output Enable, setting this low lights all the LEDs in the selected rows. Can pwm it at very high frequency for brightness control.
#define PIN_DMD_A 6 // D6
#define PIN_DMD_B 7 // D7
#define PIN_DMD_CLK 13 // D13_SCK is SPI Clock if SPI is used
#define PIN_DMD_SCLK 8 // D8
#define PIN_DMD_R_DATA 11 // D11_MOSI is SPI Master Out if SPI is used
//Define this chip select pin that the Ethernet W5100 IC or other SPI device uses
//if it is in use during a DMD scan request then scanDisplayBySPI() will exit without conflict! (and skip that scan)
#define PIN_OTHER_SPI_nCS 10

I followed this but the LED matrix is not doing anything. So, I looked up the pins on the LED matrix that I have and here is what I found:

Pin Number Pin Name Function Description
1 CS Chip Select signal input
2 CLK Chip Select clock signal input
5 WR Write data clock input
7 DATA Data output
So I'm guessing I need to assign the CLK, CS, DATA, WR in the DMD.h and I just don't know which goes to which. I figured that:

pin definiton of the LED matrix DMD.h
DATA = DMD_R_DATA (11)
CLK = DMD_CLK (13)

as for the CS and WR I don't know which to put/assign them.

Can you give me some advice on taking the readings and then showing them on the LED matrix.

I don't know if what I have provided is enough information and if not let me know.

Thank you very for taking your time and please bear with me.

cheers,

Am I supposed to know what DMD means ? Does looking at a library tell me anything about the hardware ?
Did you post a datasheet or a link to a website where you purchased said device ?

Sorry again and thank you for your patience.

On the tutorial by John, he is using this kind of LED matrix

And the one that I'm using is this

http://www.sureelectronics.net/goods.php?id=1095

Difference is that, from the tutorial John is using a 16x32 LED matrix is only RED Leds. The LED matrix that I'm using is RED GREEN Bicolour 16x32 Led matrix.

with this post I have attached the datasheet for the LED matrix that I have (w/c I bought from sure electronics). However, I couldn't find the datasheet for the LED matrix that is used in the tutorial.

Thank you and I'm really grateful for your replies

Cheers,

DE-DP14112_Ver1.1_EN.pdf (3.71 MB)

Here is the way to make your sure electronics RED GREEN Bicolour 16x32 Led matrix work
http://playground.arduino.cc/Main/HT1632C#.Uyb8vz-SzMw

Thanks for jumping in Billho, I really didn't know how to answer the question .