will be read-only starting December 31st, 2018. For more info please look at this Forum Post

LcdBarGraph Library for Arduino
Author:  Bal√°zs Kelemen



 1.0 2010-02-21: Initial Release
 1.1 2011-12-11: Make it compatible with Arduino 1.0
 1.2 2012-04-27: Fix of Robert Klotz for values greater than 1650. (Thank you Rob!)
 1.2 2012-10-08: Patch for custom positioning of the bar.
 1.3 2012-12-18: Applying "positioning" path in the official release.
 1.4 2014-03-17: Fixing an example and adding a new one.
 1.5 2015-01-03: Using built in filled character instead of creating one for ourselves. (Thank you Hans van Neck!)
x1.0 2015-05-26: The base library was forked in name LcdBarGraphX to be used with I2C displays.


LcdBarGraph is an Arduino library for displaying analog values in LCD display, which is previously initialized. This library uses LiquedCrystal library for displaying.


Watch demo on YouTube:

The inspiration was come from the video Arduino EMF detector . After watching was wondering what a big work is to build a led bar. Why not use a higher level implementation? And the LcdBarGraph was born.

Please fill free to port this idea to other LCD libraries like arduinoshiftreglcd . You might want to fork the original code, at github:

I wanted to leave LcdBarGraph as simple as possible. But the folks asked for the possibility of allow custom positioning of the bar. So, at the version 1.3 I've added this option.

I still do encourage you to make your modification in the library for your own use. (But do not forget about the GPL license, so please publish your modifications!)

Do not hesitate to contact me if you have some wishes, or just find the library useful.

The base library now has a fork to be used with "F. Malpartida" version LCD lib, so to be able to use I2C displays. (

Thanks goes to

  • Robert Klotz
  • Hans van Neck
  • John Pateman

Download, install

Download here:

  • - Initial release (Use values less than 1650!)
  • - Use for Arduino v1.0 or later
  • - This patch modifies the original v1.2 sources, so that you may position the bar in your LCD with a very little footprint penalty.
  • - Same as the version 1.2 but with the position option patch applied. (It enlarges the footprint by 12 bytes, but adds a great functionality.)
  • - Same as the version 1.3 but with an example was fixed, and a new example was added.
  • - Reduced footprint by 26 bytes with using build in filled character. DOWNLOAD THIS VERSION

Download the I2C compatible version (if unsure, use the one above ^):

  • - Initial version of the custom, I2C compatible fork. Note that you will need a custom library called "LCD Library" for this version instead of the stock LiquidChrystal. See details about LCD Library here.

How to install:

  1. Extract the zip in your library folder.
  2. Rename folder to "LcdBarGraph" (if necessary).
  3. Restart the Arduino Ide.


First you need to set up the LiquidCrystal library as usual. After this you can create LcdBarGraph instance with the just created LiquidCrystal instance. You should pass the reference of the LiquidCrystal to the constructor of the LcdBarGraph, as you can see in the example.

You also need to specify the number of character columns in the LCD which is unfortunately not available from the official LiquidCrystal library.

You may use as many instances of LcdBarGraphs even on the same LiquidCrystal you want. See the MoreGraphs example.


draw(int value, int maxValue)

Draw a bargraph with a value between 0 and maxValue.


  1. #include <LiquidCrystal.h>
  2. #include <LcdBarGraph.h>
  4. byte lcdNumCols = 16; // -- number of columns in the LCD
  5. byte sensorPin = 0; // -- value for this example
  7. LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // -- creating LCD instance
  8. LcdBarGraph lbg(&lcd, lcdNumCols);  // -- creating bargraph instance, format is (&lcd, lcdNumCols, start X, start Y). So (&lcd, 16, 0, 1) would set the bargraph length to 16 columns and start the bargraph at column 0 on row 1.
  10. void setup(){
  11.   // -- initializing the LCD
  12.   lcd.begin(2, lcdNumCols);
  13.   lcd.clear();
  14.   // -- do some delay some time I've got broken visualization
  15.   delay(100);
  16. }
  18. void loop()
  19. {
  20.   // -- draw bar graph from the analog value readed
  21.   lbg.drawValue( analogRead(sensorPin), 1024);
  22.   // -- do some delay: frequent draw may cause broken visualization
  23.   delay(100);
  24. }


  • I see strange characters in the place, where filled characters should be seen. - Please comment the USE_BUILDIN_FILLED_CHAR definition in the LcdBarGraph.h, so the library will generate its own filled character.
  • I see strange characters in the last place. - Actually the library has a bug since it starts uploading custom fonts to the LCD before it was initialized with the "begin()" method. But as no problems are reported this won't be fixed. However the version LcdBarGraphX version does the job right, and do not suffer from this bug.

Information about this page

Last Modified: May 27, 2015, at 05:24 PM