Bargraph Meters LCD horizontal vertical peak linear log parallel or serial I2C !

Please find here my functions to print on a LCD text display (compatible Hitachi HD44780) up to 40 simultaneus bars :fearful:, with different positions, lengths, linear progression or audio logarithmic, with/without peak memory display.
They can be used as progression bars, level meters, audio VUmeters, visually show any measurement or level you like to.

Types of bars can be mixed but all must only be horizontal OR vertical. This is due to display's customized characters limitation, so I was forced to write one function for horizontal bars/meters and another for vertical ones giving priority to the precision of the bars.

Main features:

  • easy to embed in your projects, it doesn't use delays or delay loops in order to take the shortest CPU time possible and free CPU for your main application
  • precise: it uses every dot of the display
  • linear and audio logarithmic option, just with a parameter
  • HORIZONTAL bars: peak indicator memory option in the same bar with expiration time adjustment
  • VERTICAL bars: peak or standard bars: due to custom characters limitations it's not possible to have a cool bar like the horizontal ones :~
  • it works with different display sizes (eg. 16x2 20x4)
  • direct connection Arduino==display, no need of a serial converter in the middle
  • I enclose also same scketches for serial LCD I2C versions interface (PCF8574T based) if you need to save I/O
  • 4 wires parallel versions uses standard Arduino libraries
  • serial I2C versions require to use libraries by F Malpartida and remove the Arduino libraries from program folder, instructions in the comments of sketches

Is your task obviously to check that position and maximum length of each bar stay inside the display... :slight_smile:

Below images and codes, enjoy free, I will appreciate comments and see projects using them! :smiley:


Example of several bars showing a typical stereo L-R audio logarithmic VUmeters, with peak memory, two different sizes: 3 in the top, 17 below.
In the middle one linear bar, length 17, without peak memory (but it can be activated).


Example using the VER version, showing 10 audio logarithmic bars, lengh 2 with sidebar peak memory. One linear peak bar, length 4. Two audio logarithmic L-R VUmeters, length 4, with peak memory bars in the centre.

Enclosed below the codes for HORIZONTAL BARS and the one for VERTICAL BARS.

*** Updated 13 april with v 1.2 :

  • better circuit description
  • better comments

*** Updated 15 april VER only with v 1.3 :

  • you can print peak bar only if you wish

*** Added 17 may same two versions

  • for I2C PCF8574T based interface serial controller
    in this case remember to remove any LiquidCrystal library in the user library folder and in the Arduino program one

*** updated 17/06/2014 more comments, identical code

(if you like this post pls click my karma! XD )

NiceMetersHOR_1_2.ino (8.03 KB)

NiceMetersVER_1_3.ino (8.32 KB)

NiceMetersHOR_1_2_I2C.ino (8.08 KB)

NiceMetersVER_1_3_I2C.ino (8.32 KB)

Thx for sharing :slight_smile:

Very nice bars. I used your horizontal bars on my manometer project. These bars/meters are very scalable bars and are worthy of a bar graph library. Have you considered writing them into a library? Regardless, I have been referring to your to your bars as "Bob bars" for short.

Thanks again and keep up the good work,
Stievenart

Hi,
Can i create 2 different bar for analog 0 and analog 1 ?

i try

void loop() {

 unsigned int value = analogRead(0);
 perc = value/1023.0*100;       
 logar = false; 
 bn =1;                     // for bar No1
 for (int i=1;i<41;i++)  // setting 15 cycles for all bars... YOUR CHOICE !!
     { pkcyc[i][1]=  15;}


unsigned int value = analogRead(1);
 perc = value/1023.0*100;       
 logar = false; 
 bn =2;                      // for bar No2
 for (int i=1;i<41;i++)  // setting 15 cycles for all bars... YOUR CHOICE !!
     { pkcyc[i][1]=  15;}


lcd.setCursor(0,0); 
lcd.print (analogRead(0));
lcd.print((char)223);// 
lcd.print ("C 21:30 B");   // waiting for the RTC board
lcd.print (analogRead(1));

lcd.setCursor(0,1); 
pkcyc[1][1]=  0;
printbar (1,perc,0,1,10, false);    //bar No 1

pkcyc[2][1]=  0;
printbar (2,perc,10,1,10, false);  // bar No2