Display FSRs level on LCD

Thread Starter

Amy Yu

Joined Oct 14, 2015
5
My project is dealing with 4 FSR sensors with arduino. I would like to display the pressure level of all 4 sensors inputs on a LCD screen all at once. I've written the codes by referring to relevant sources, but I'm uncertain if my coding is functioning as I'm completely new in this, wish to hear some comments on these, thanks.



#include<LiquidCrystal.h>
Liquid Crystal lcd(12, 11, 5, 4, 3, 2);//set pins for LCD

int fsr1 = 0;//fsr1 connected to analog pin 0
int fsr2 = 1;//fsr2 connected to analog pin 1
int fsr3 = 2;//fsr3 connected to analog pin 2
int fsr4 = 3;//fsr4 connected to analog pin 3

//variables for level of force applied to FSRs
int fsr1level = 0;
int fsr2level = 0;
int fsr3level = 0;
int fsr4level = 0;

void setup()
{
lcd.begin(16, 2);//set up LCD no.of columns & rod
}

void loop()
{
//divide by four as analog read is 4x sensitive as digital
fsr1level = analog Read(fsr1) / 4;
fsr2level = analog Read(fsr2) / 4;
fsr3level = analog Read(fsr3) / 4;
fsr4level = analog Read(fsr4) / 4;

//display pressure level on LCD
lcd.setCursor(0, 0);
lcd.print(fsr1level);
lcd.setCursor(15, 0);
lcd.print(fsr2level);
lcd.setCursor(0, 1);
lcd.print(fsr3level);
lcd.setCursor(15, 1);
lcd.print(fsr4level);
}
 
Top