/* How to use a Force sensitive resistor to fade an LED with Arduino
   More info: http://www.ardumotive.com/how-to-use-a-force-sensitive-resistor-en.html
   Dev: Michalis Vasilakis // Date: 22/9/2015 // www.ardumotive.com  */
 
//Constants:
// const int ledPin = 3;     //pin 3 has PWM funtion
const int sensorPin = 0; //pin A0 to read analog input
float force; // décalration de la variable force
#include <Wire.h>                 //importation des librairies
#include <rgb_lcd.h>              //pour l'afficheur
rgb_lcd lcd;                      //creation de l'objet afficheur
 
//Variables:
float value; //save analog value
 
 
void setup(){
 
//  pinMode(ledPin, OUTPUT);  //Set pin 3 as 'output'
  Serial.begin(9600);       //Begin serial communication
    lcd.begin(16, 2);           //configure l'afficheur 16 lig 2 col
    lcd.setRGB(50, 50, 50);    //couleur de fond (R, G, B)
    lcd.setColor(255);
   
}
 
void loop(){
 lcd.clear();
  value = analogRead(sensorPin);       //Read and save analog value from potentiometer
  Serial.println(value);               //Print value
  force = value*0.34;
  lcd.setCursor(0, 0);
   lcd.print("Force :");     //affichage 1ere ligne
 lcd.setCursor(0, 1);
  lcd.print(force);
   lcd.setCursor(7, 1);
  lcd.print(" Newtons");
lcd.display();
  Serial.print("La force est = ");
  Serial.print(force);
  Serial.println( " Newtons");
  delay(250);                          //Small delay
 
}
