Hi!
Im pretty new to this forum but i have heard that its an good place to ask questions
My problem is, i am trying to display the min and max values from an voltage source.
I wrote/put together this code wich works realy well, exept i cannot get the values to work corectly..
What i am trying to acieve is writing it out like this:
Volt= 0.00
Minv= (min value from volt) Maxv= (max value from volt)
(emty)
Gain xxx%
What i have tryed to implement is different codes from wetherstations (max min temp converted for my volt)
But how i try i cant get it to work propertly..
I guess this is less of an what is wrong and more how do i do it
If anyone would be able to help i would appreciate it alot!
Thanks
The code atm:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int analogInput = 0;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000.0; // resistance of R1 (100K) -see text!
float R2 = 10000.0; // resistance of R2 (10K) - see text!
int value = 0;
int potPin = A1; //Potentiometer input pin
int potValue1 = 0;
int potValue2 = 0; // final display variable
void setup(){
pinMode(analogInput, INPUT);
lcd.begin(20, 3);
lcd.setCursor(0,1);
lcd.print("GAIN");
}
void loop(){
// read then divide the input(max 1020 in this case) by 10
potValue1 = analogRead(potPin) / 10;
// divide by 1.02 to get percentage
potValue2 = potValue1 / 1.02;
// set cursor to second row, first column
lcd.setCursor(6, 1);
//display final percentage
lcd.print(potValue2);
//print the percent symbol at the end
lcd.print("%");
//wait 0.1 seconds
delay(20);
//wipe the extra characters
lcd.print(" ");
delay(1);
// read the value at analog input
value = analogRead(analogInput);
vout = (value * 5.0) / 1024.0; // see text
vin = vout / (R2/(R1+R2));
if (vin<0.09) {
vin=0.0;//statement to quash undesired reading !
}
lcd.setCursor(0, 0);
lcd.print("Volt= ");
lcd.print(vin);
delay(400);
}