Hello,
I am trying to use a Sainsmart LCD2004 IIC Display to show a scpetrum analyzer that displays data coming from an MSGEQ7 filter. The MSGEQ7 breaks and audio signal into an analog array that is then readable by the arduino, I would then like to display these 7 frequency bands using columns as the frequency and height as the strength or strength/loudness of that frequency. I found a horizontal bar graph library, but I can't figure out how to do a vertical one. I found a youtube video of someone that did it, but they are using a printer port and LCDsmartie with the winamp plugin. Is there anyway that I can do the same using an MSGEQ7 and Arduino? My overall project is SMARTLEDs, LEDs that you can control form your Infrared-enabled phone and also sync the LEDs to music from an mp3 jack(which I have already got), and then perhaps have a display so I know what is going into the arduino when it isn't plugged into my pc. Any advice would be great.
It is exactly the same idea. You have 8 user defined characters.
A horizontal bargraph uses thin and wide blocks.
A vertical bargraph would have short and high blocks.
Whichever way you do things, a character display will always have gaps between each character.
A graphics display can give you a nicer looking view.
Yes but the display is 20x4, but the code library thinks it's a 4x20 which is extremely frustrating. The library won't allow me to change that. I tried LcdBarGraphX lbg0(&lcd, 2, 0, 3); which says 2 columns wide, starting at column 0 on row 3. It doesn't display up, but to the side. How do I make it go from row 3 to row 0 instead of column 0 to column 1?
// -- creating a 4 chars wide bars - NO OPTION FOR VERTICAL, only horizontal?
LcdBarGraphX lbg0(&lcd, 2, 0, 3);
byte i0 = 0;
void setup(){
// -- initializing the LCD
lcd.begin(4, lcdNumCols);
lcd.clear();
// -- do some delay: some time I've got broken visualization
delay(100);
}
void loop()
{
// -- draw bar graph from the analog value readed
lbg0.drawValue( i0, 255);
// -- do some delay: frequent draw may cause broken visualization
delay(100);
I just looked at the source code on GitHub. It only supports Horizontal bar graphs.
But the code is so simple that you could create your own LcdBarGraphY class.
Yes, it would be acceptable on a 20x4 display. It would be a bit useless on a 16x2.
Yes but the display is 20x4, but the code library thinks it's a 4x20 which is extremely frustrating.
The only difference between the two is the order in which the dimensions are expressed. I suspect that 20x4 is more 'correct' since that designation is implied by the part number 'LCD2004'.
Keep in mind that you are at the mercy of how the author of the library interprets things. The LCD controller itself deals only with memory addresses since there is no way to inform the controller about the configuration of the device that it is driving. The library author has written code to translate his interpretation of rows and columns to LCD memory addresses and you have to figure this out as you work with the library.
@david_prentice,
I looked at the code as well and I can't make heads or tails of it. I know how to use the LcdBarGraphX class, but I have no idea how to switch the dimensions around as I have tried swapping them in the init of the display in my script above but that still does not make it go vertical. I have no idea how to switch the dimensions.
. I found a horizontal bar graph library, but I can't figure out how to do a vertical one.
You cannot manipulate THEIR graph class because it is HORIZONTAL special character based, whatever its shape is, probably just simple "-" dash. And the resolution of such graph would be one "-" character written up to 20 times in one row.
You need to code it yourself from scratch and do few things
Build special characters - pixels centered in the character field
1 pixel - probably standard "." period will do
2 pixels
...
8 pixexs
The 5x8 character is 8 pixels high
Than you would have to calculate each graph bar - consisting of count of "standard bar "|" plus your "top" special character.
Than you would output these in selected LCD position
write 1st graph character @ first row (1 out of 4 ) @ position ( 1 out of 20 )
....
write 4th graph character @ fourth row (1 out of 4 ) @ position ( 1 out of 20 )
The graph would probably look better using characters 9 pixels high, characters 8 pixels high actually do not use the all of pixels available ( most of the time).