So we were asked to do something with a force sensitive resistor so naturally i thought of a project which takes the name of the main component which is force and applies it ,mine works by as you apply more and more pressure to the sensor it takes this value and displays it on an lcd but the display should be a bar graph which increases as the pressure increases. the problem is i dont really know how to do a bar graph on a 16x2 lcd. Please help. (my lcd has an I2c)
here is my code for the pressure sensor so far
int fsrAnalogPin = 0; // FSR is connected to analog 0
int fsrReading; // the analog reading from the FSR resistor divider
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
fsrReading = analogRead(fsrAnalogPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);
delay(100);
}
ok so i improved my code and i finally got it this code displays the force detected by the fsr into a bar graph
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LcdBarGraphX.h>
#include<LcdBarGraph.h>
byte lcdNumCols = 20; // -- number of columns in the LCD
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // -- creating LCD instance
int fsrAnalogPin = 0; // FSR is connected to A0
// -- creating a 4 chars wide bars
LcdBarGraphX lbg0(&lcd, 16, 0, 0); // -- First line at column 0 and row 0 with 16 columns
void setup(void) {
Serial.begin(9600); // We'll send debugging information via the Serial monitor
lcd.begin(4, lcdNumCols); // start lcd with 2 rows and 16 columns
lcd.clear();
delay(100);
}
void loop(void) {
lbg0.drawValue( analogRead(fsrAnalogPin), 9); // the 9 is the maximum range you want for pressure
Serial.print("Analog reading = ");
Serial.println(fsrReading);
delay(100);
}