LcdProgressBarDouble

LcdProgressBarDouble © GPL3+

LcdProgressBarDouble is an Arduino library for displaying a 2 progress bars in a single row in LCD display.

  • 2,480 views
  • 3 comments
  • 10 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
181 02
Adafruit Standard LCD - 16x2 White on Blue
Will work with any supported LCD by LiquidCrystal library
×1

About this project

What is LcdProgressBarDouble?

LcdProgressBarDouble displays two progress bars in a single row of LCD display.

Dependencies

The LCD display must be previously initialized. This library uses LiquidCrystal library for displaying.

Expected result

LcdProgressBarDouble in action (timer example)!

Example 1: Timer

Refer to full example: examples/DoubleTimer/DoubleTimer.ino.

Includes

#include <LiquidCrystal.h>
 

Initialization: instantiations

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 

Initializing the progress bar

void initLpg()
{
  startedMillis1 = millis();
  startedMillis2 = startedMillis1;
  //-- Set min and max values
  lpg.setMinValues(startedMillis1);
  lpg.setMaxValues(startedMillis1 + duration1, startedMillis2 + duration2);
  //-- Draw it
  lpg.draw(startedMillis1);
}

Drawing the progress bar

//-- draw progress bar
lpg.draw(currentMillis);

or via the alias drawValues (the LcdBarGraph way):

//-- draw progress bar
lpg.drawValues(currentMillis);

Example 2: Trimmer potentiometers

Refer to full example: examples/DoubleBarPot/DoubleBarPot.ino.

Though the circuit is slightly more complex, the code is way easier!

Expected

LcdProgressBarDouble in action (trimmers example)!

Initializing the progress bar

//-- Set min and max values
//*** (0 is default minimum value)
//*** (1023 is maximum value for both bars)
lpg.setMaxValues(1023);

Drawing the progress bar

int r4 = analogRead(pinR4);
int r5 = analogRead(pinR5);
//-- draw progress bars
lpg.draw(r4, r5);

Major releases

  • v1.0.0: Initial release
  • v1.0.3: Added support to display 1 bar only
  • v1.1.0: Use of PROGMEM to save some RAM. Comment this line to prevent this behavior:
#define LCDPROGRESSBAR_USE_PROGMEM

Code

DoubleTimer.inoC/C++
Double progress bars demo
/*
  DoubleTimer.ino - v1.0.0 - 2016-08-01

  Showcase of LcdProgressBarDouble library: displays a 2 progress bars in a single row in LCD display,
  which is previously initialized. This library uses LiquidCrystal library for displaying.

  Copyright (c) 2016 Wilfried Loche.  All rights reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 3 of the License, or (at your option) any later version.

  See file LICENSE.txt for further informations on licensing terms.
*/
#include <LiquidCrystal.h>
#include <LcdProgressBarDouble.h>

byte lcdNumCols = 16; // -- number of columns in the LCD

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LcdProgressBarDouble lpg(&lcd, 1, lcdNumCols);

unsigned long duration1 = 20000; // 8000 milliseconds, 8 seconds
unsigned long duration2 = 10000; // 2000 milliseconds, 2 seconds
unsigned long startedMillis1  = 0;
unsigned long startedMillis2  = 0;

void setup() {
  //-- Only useful for debugging purpose
  Serial.begin(115200);

  //-- initializing the LCD
  lcd.begin(2, lcdNumCols);
  lcd.clear();

  lcd.setCursor(0, 0);
  lcd.print("LcdProgressBar*2");
      
  delay(100);

  //-- initializing the progress bar
  initLpg();
}

//-- initializing the progress bars
void initLpg()
{
  //-- start time
  startedMillis1 = millis();
  startedMillis2 = startedMillis1;

  //-- Set min and max values
  lpg.setMinValues(startedMillis1);
  lpg.setMaxValues(startedMillis1 + duration1, startedMillis2 + duration2);

  //-- Draw it
  lpg.draw(startedMillis1);
}

void loop() {

  unsigned long currentMillis = millis();

  //-- draw progress bar
  lpg.draw(currentMillis);

  if ((unsigned long)(currentMillis - startedMillis1) > duration1) {
    //--- Bargraph 1 duration's over: delay and start again!
    startedMillis1 += duration1;
    //lpg.setMinValue1(startedMillis1);
    //lpg.setMaxValue1(startedMillis1 + duration1);

    //--- Shortcut of 2 previous methods
    lpg.setRangeValue1(startedMillis1, startedMillis1 + duration1);
  }

  if ((unsigned long)(currentMillis - startedMillis2) > duration2) {
    //--- Bargraph 2 duration's over: delay and start again!
    startedMillis2 += duration2;
    
    //lpg.setMinValue2(startedMillis2);
    //lpg.setMaxValue2(startedMillis2 + duration2);

    //--- Shortcut of 2 previous methods
    lpg.setRangeValue2(startedMillis2, startedMillis2 + duration2);
  }

  // -- do some delay: frequent draw may cause broken visualization
  delay(100);
}
DoubleBarPot.inoC/C++
Showcase of LcdProgressBarDouble library: displays a 2 progress bars in a single row in LCD display (from 2 trimmer potentiometers)
/*
  DoubleBarPot.ino - v1.0.2 - 2016-08-01

  Showcase of LcdProgressBarDouble library: displays a 2 progress bars in a single row in LCD display (from 2 trimmer potentiometers),
  which is previously initialized. This library uses LiquidCrystal library for displaying.

  Copyright (c) 2016 Wilfried Loche.  All rights reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 3 of the License, or (at your option) any later version.

  See file LICENSE.txt for further informations on licensing terms.
*/
#include <LiquidCrystal.h>
#include <LcdProgressBarDouble.h>

byte lcdNumCols = 16; // -- number of columns in the LCD

const int pinR4 = A4;
const int pinR5 = A5;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LcdProgressBarDouble lpg(&lcd, 1, lcdNumCols);

void setup()
{
  //-- Only useful for debugging purpose
  Serial.begin(115200);

  //-- initializing the LCD
  lcd.begin(2, lcdNumCols);
  lcd.clear();

  lcd.setCursor(0, 0);
  lcd.print("LcdProgressBar*2");

  //-- Set min and max values
  //*** (0 is default minimum value)
  //*** (1023 is maximum value for both bars)
  lpg.setMaxValues(1023);
      
  delay(50);
}

void loop()
{
  int r4 = analogRead(pinR4);
  int r5 = analogRead(pinR5);
  
  //-- draw progress bars
  lpg.draw(r4, r5);

  // -- do some delay: frequent draw may cause broken visualization
  delay(50);
}
GitHub
LcdProgressBarDouble Git repository on GitHub

Schematics

Breadboard (Timer)
Follow the wires and you'll get the the demo working like a charm :).
Lcdprogressbardouble bb
Schema (Timer)
If you prefer, here is the electric schematic
Lcdprogressbardouble schema
Breadboard (trimmer potentiometers)
Lcdprogressbarpot bb
Schema (trimmer potentiometers)
Lcdprogressbarpot schema
Fritzing schemas (with trimmer potentiometers)
For timer example, simply remove the 2 potentiometers connected to A4 and A5 analog entries.
LcdProgressBarPot.fzz

Comments

Similar projects you might like

LcdProgressBar

by Wilfried Loche

  • 2,423 views
  • 0 comments
  • 7 respects

LCD (Liquid Crystal Display)

by MicroBob

  • 30,778 views
  • 41 comments
  • 101 respects

Displaying Sensor Values on LCD

by Wimpie van den Berg

  • 42,769 views
  • 4 comments
  • 36 respects

Food Detector

Project tutorial by crispylel

  • 35,424 views
  • 7 comments
  • 91 respects

Arduino LCD Thermostat

Project tutorial by Arduino “having11” Guy

  • 15,383 views
  • 22 comments
  • 30 respects

LCD1602MkrUnoShield

by zhaoshentech

  • 1,365 views
  • 0 comments
  • 4 respects
Add projectSign up / Login