Devices & Components
Arduino Uno Rev3
Standard LCD - 16x2 White on Blue
Project description
Code
GitHub
LcdProgressBarDouble Git repository on GitHub
DoubleBarPot.ino
c_cpp
Showcase of LcdProgressBarDouble library: displays a 2 progress bars in a single row in LCD display (from 2 trimmer potentiometers)
1/* 2 DoubleBarPot.ino - v1.0.2 - 2016-08-01 3 4 Showcase of LcdProgressBarDouble 5 library: displays a 2 progress bars in a single row in LCD display (from 2 trimmer 6 potentiometers), 7 which is previously initialized. This library uses LiquidCrystal 8 library for displaying. 9 10 Copyright (c) 2016 Wilfried Loche. All rights 11 reserved. 12 13 This library is free software; you can redistribute it and/or 14 15 modify it under the terms of the GNU Lesser General Public 16 License as published 17 by the Free Software Foundation; either 18 version 3 of the License, or (at your 19 option) any later version. 20 21 See file LICENSE.txt for further informations 22 on licensing terms. 23*/ 24#include <LiquidCrystal.h> 25#include <LcdProgressBarDouble.h> 26 27byte 28 lcdNumCols = 16; // -- number of columns in the LCD 29 30const int pinR4 = A4; 31const 32 int pinR5 = A5; 33 34LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 35LcdProgressBarDouble 36 lpg(&lcd, 1, lcdNumCols); 37 38void setup() 39{ 40 //-- Only useful for debugging 41 purpose 42 Serial.begin(115200); 43 44 //-- initializing the LCD 45 lcd.begin(2, 46 lcdNumCols); 47 lcd.clear(); 48 49 lcd.setCursor(0, 0); 50 lcd.print("LcdProgressBar*2"); 51 52 53 //-- Set min and max values 54 //*** (0 is default minimum value) 55 //*** 56 (1023 is maximum value for both bars) 57 lpg.setMaxValues(1023); 58 59 60 delay(50); 61} 62 63void loop() 64{ 65 int r4 = analogRead(pinR4); 66 int 67 r5 = analogRead(pinR5); 68 69 //-- draw progress bars 70 lpg.draw(r4, r5); 71 72 73 // -- do some delay: frequent draw may cause broken visualization 74 delay(50); 75} 76
DoubleTimer.ino
c_cpp
Double progress bars demo
1/* 2 DoubleTimer.ino - v1.0.0 - 2016-08-01 3 4 Showcase of LcdProgressBarDouble 5 library: displays a 2 progress bars in a single row in LCD display, 6 which is 7 previously initialized. This library uses LiquidCrystal library for displaying. 8 9 10 Copyright (c) 2016 Wilfried Loche. All rights reserved. 11 12 This library 13 is free software; you can redistribute it and/or 14 modify it under the terms 15 of the GNU Lesser General Public 16 License as published by the Free Software 17 Foundation; either 18 version 3 of the License, or (at your option) any later 19 version. 20 21 See file LICENSE.txt for further informations on licensing terms. 22*/ 23#include 24 <LiquidCrystal.h> 25#include <LcdProgressBarDouble.h> 26 27byte lcdNumCols = 28 16; // -- number of columns in the LCD 29 30LiquidCrystal lcd(12, 11, 5, 4, 3, 31 2); 32LcdProgressBarDouble lpg(&lcd, 1, lcdNumCols); 33 34unsigned long duration1 35 = 20000; // 8000 milliseconds, 8 seconds 36unsigned long duration2 = 10000; // 37 2000 milliseconds, 2 seconds 38unsigned long startedMillis1 = 0; 39unsigned long 40 startedMillis2 = 0; 41 42void setup() { 43 //-- Only useful for debugging purpose 44 45 Serial.begin(115200); 46 47 //-- initializing the LCD 48 lcd.begin(2, lcdNumCols); 49 50 lcd.clear(); 51 52 lcd.setCursor(0, 0); 53 lcd.print("LcdProgressBar*2"); 54 55 56 delay(100); 57 58 //-- initializing the progress bar 59 initLpg(); 60} 61 62//-- 63 initializing the progress bars 64void initLpg() 65{ 66 //-- start time 67 startedMillis1 68 = millis(); 69 startedMillis2 = startedMillis1; 70 71 //-- Set min and max 72 values 73 lpg.setMinValues(startedMillis1); 74 lpg.setMaxValues(startedMillis1 75 + duration1, startedMillis2 + duration2); 76 77 //-- Draw it 78 lpg.draw(startedMillis1); 79} 80 81void 82 loop() { 83 84 unsigned long currentMillis = millis(); 85 86 //-- draw progress 87 bar 88 lpg.draw(currentMillis); 89 90 if ((unsigned long)(currentMillis - startedMillis1) 91 > duration1) { 92 //--- Bargraph 1 duration's over: delay and start again! 93 94 startedMillis1 += duration1; 95 //lpg.setMinValue1(startedMillis1); 96 97 //lpg.setMaxValue1(startedMillis1 + duration1); 98 99 //--- Shortcut of 100 2 previous methods 101 lpg.setRangeValue1(startedMillis1, startedMillis1 + duration1); 102 103 } 104 105 if ((unsigned long)(currentMillis - startedMillis2) > duration2) { 106 107 //--- Bargraph 2 duration's over: delay and start again! 108 startedMillis2 109 += duration2; 110 111 //lpg.setMinValue2(startedMillis2); 112 //lpg.setMaxValue2(startedMillis2 113 + duration2); 114 115 //--- Shortcut of 2 previous methods 116 lpg.setRangeValue2(startedMillis2, 117 startedMillis2 + duration2); 118 } 119 120 // -- do some delay: frequent draw 121 may cause broken visualization 122 delay(100); 123} 124 125
GitHub
LcdProgressBarDouble Git repository on GitHub
DoubleBarPot.ino
c_cpp
Showcase of LcdProgressBarDouble library: displays a 2 progress bars in a single row in LCD display (from 2 trimmer potentiometers)
1/* 2 DoubleBarPot.ino - v1.0.2 - 2016-08-01 3 4 Showcase of LcdProgressBarDouble library: displays a 2 progress bars in a single row in LCD display (from 2 trimmer potentiometers), 5 which is previously initialized. This library uses LiquidCrystal library for displaying. 6 7 Copyright (c) 2016 Wilfried Loche. All rights reserved. 8 9 This library is free software; you can redistribute it and/or 10 modify it under the terms of the GNU Lesser General Public 11 License as published by the Free Software Foundation; either 12 version 3 of the License, or (at your option) any later version. 13 14 See file LICENSE.txt for further informations on licensing terms. 15*/ 16#include <LiquidCrystal.h> 17#include <LcdProgressBarDouble.h> 18 19byte lcdNumCols = 16; // -- number of columns in the LCD 20 21const int pinR4 = A4; 22const int pinR5 = A5; 23 24LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 25LcdProgressBarDouble lpg(&lcd, 1, lcdNumCols); 26 27void setup() 28{ 29 //-- Only useful for debugging purpose 30 Serial.begin(115200); 31 32 //-- initializing the LCD 33 lcd.begin(2, lcdNumCols); 34 lcd.clear(); 35 36 lcd.setCursor(0, 0); 37 lcd.print("LcdProgressBar*2"); 38 39 //-- Set min and max values 40 //*** (0 is default minimum value) 41 //*** (1023 is maximum value for both bars) 42 lpg.setMaxValues(1023); 43 44 delay(50); 45} 46 47void loop() 48{ 49 int r4 = analogRead(pinR4); 50 int r5 = analogRead(pinR5); 51 52 //-- draw progress bars 53 lpg.draw(r4, r5); 54 55 // -- do some delay: frequent draw may cause broken visualization 56 delay(50); 57} 58
DoubleTimer.ino
c_cpp
Double progress bars demo
1/* 2 DoubleTimer.ino - v1.0.0 - 2016-08-01 3 4 Showcase of LcdProgressBarDouble library: displays a 2 progress bars in a single row in LCD display, 5 which is previously initialized. This library uses LiquidCrystal library for displaying. 6 7 Copyright (c) 2016 Wilfried Loche. All rights reserved. 8 9 This library is free software; you can redistribute it and/or 10 modify it under the terms of the GNU Lesser General Public 11 License as published by the Free Software Foundation; either 12 version 3 of the License, or (at your option) any later version. 13 14 See file LICENSE.txt for further informations on licensing terms. 15*/ 16#include <LiquidCrystal.h> 17#include <LcdProgressBarDouble.h> 18 19byte lcdNumCols = 16; // -- number of columns in the LCD 20 21LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 22LcdProgressBarDouble lpg(&lcd, 1, lcdNumCols); 23 24unsigned long duration1 = 20000; // 8000 milliseconds, 8 seconds 25unsigned long duration2 = 10000; // 2000 milliseconds, 2 seconds 26unsigned long startedMillis1 = 0; 27unsigned long startedMillis2 = 0; 28 29void setup() { 30 //-- Only useful for debugging purpose 31 Serial.begin(115200); 32 33 //-- initializing the LCD 34 lcd.begin(2, lcdNumCols); 35 lcd.clear(); 36 37 lcd.setCursor(0, 0); 38 lcd.print("LcdProgressBar*2"); 39 40 delay(100); 41 42 //-- initializing the progress bar 43 initLpg(); 44} 45 46//-- initializing the progress bars 47void initLpg() 48{ 49 //-- start time 50 startedMillis1 = millis(); 51 startedMillis2 = startedMillis1; 52 53 //-- Set min and max values 54 lpg.setMinValues(startedMillis1); 55 lpg.setMaxValues(startedMillis1 + duration1, startedMillis2 + duration2); 56 57 //-- Draw it 58 lpg.draw(startedMillis1); 59} 60 61void loop() { 62 63 unsigned long currentMillis = millis(); 64 65 //-- draw progress bar 66 lpg.draw(currentMillis); 67 68 if ((unsigned long)(currentMillis - startedMillis1) > duration1) { 69 //--- Bargraph 1 duration's over: delay and start again! 70 startedMillis1 += duration1; 71 //lpg.setMinValue1(startedMillis1); 72 //lpg.setMaxValue1(startedMillis1 + duration1); 73 74 //--- Shortcut of 2 previous methods 75 lpg.setRangeValue1(startedMillis1, startedMillis1 + duration1); 76 } 77 78 if ((unsigned long)(currentMillis - startedMillis2) > duration2) { 79 //--- Bargraph 2 duration's over: delay and start again! 80 startedMillis2 += duration2; 81 82 //lpg.setMinValue2(startedMillis2); 83 //lpg.setMaxValue2(startedMillis2 + duration2); 84 85 //--- Shortcut of 2 previous methods 86 lpg.setRangeValue2(startedMillis2, startedMillis2 + duration2); 87 } 88 89 // -- do some delay: frequent draw may cause broken visualization 90 delay(100); 91} 92 93
Downloadable files
Fritzing schemas (with trimmer potentiometers)
For timer example, simply remove the 2 potentiometers connected to A4 and A5 analog entries.
Fritzing schemas (with trimmer potentiometers)
Breadboard (trimmer potentiometers)
Breadboard (trimmer potentiometers)

Breadboard (Timer)
Follow the wires and you'll get the the demo working like a charm :).
Breadboard (Timer)

Fritzing schemas (with trimmer potentiometers)
For timer example, simply remove the 2 potentiometers connected to A4 and A5 analog entries.
Fritzing schemas (with trimmer potentiometers)
Schema (trimmer potentiometers)
Schema (trimmer potentiometers)

Breadboard (trimmer potentiometers)
Breadboard (trimmer potentiometers)

Schema (Timer)
If you prefer, here is the electric schematic
Schema (Timer)

Schema (trimmer potentiometers)
Schema (trimmer potentiometers)

Breadboard (Timer)
Follow the wires and you'll get the the demo working like a charm :).
Breadboard (Timer)

Comments
Only logged in users can leave comments