Skip to content

Instantly share code, notes, and snippets.

@cbscribe
Created April 19, 2021 21:48
Show Gist options
  • Save cbscribe/00483e02b4e009cba3b38706b08df4a3 to your computer and use it in GitHub Desktop.
Save cbscribe/00483e02b4e009cba3b38706b08df4a3 to your computer and use it in GitHub Desktop.
Arduino+LCD Bar Graph Example
#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