Created
April 19, 2021 21:48
-
-
Save cbscribe/00483e02b4e009cba3b38706b08df4a3 to your computer and use it in GitHub Desktop.
Arduino+LCD Bar Graph Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal.h> | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
void setup() | |
{ | |
lcd.begin(16, 2); | |
} | |
void loop() | |
{ | |
lcd.clear(); | |
int force = analogRead(A5); | |
lcd.setCursor(0, 0); | |
lcd.print(force); | |
int bar = map(force, 0, 466, 0, 15); | |
lcd.setCursor(0, 1); | |
for (int i=0; i<=bar; i++) | |
{ | |
lcd.print("#"); | |
} | |
delay(250); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment