Hi
This is a DC voltmeter with displaying max value of DC voltage ( max DC hold ).
const int analogIn = PA7;
float U1 = 0.0;
float maxValue = 0;
//double maxValue = 0;
#include <LiquidCrystal.h>
LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);
float val = 0;// define the variable as value=0
void setup()
{
lcd.begin(16, 2);
}
void loop()
{
val = analogRead(PA7);
U1 = (val * 3.3) / 4.096;
if (val > maxValue)
{
maxValue = val;
}
lcd.setCursor(0, 0);
lcd.print(U1, 0); //Print the number of val on the LCD
lcd.setCursor(5, 0);
lcd.print(maxValue, 0);
delay(200); //Wait for 200ms
}
Rotating potentiometer 5 times back and forth I want to display all 5 different max values,
This is what I did, but it is obviously that all max are the same. How to make them different ?
const int analogIn = PA7;
float U1 = 0.0;
float maxValue = 0;
//++++++++++++++++++++++
float maxValue1 = 0;
float maxValue2 = 0;
float maxValue3 = 0;
float maxValue4 = 0;
float maxValue5 = 0;
//+++++++++++++++++++++++
#include <LiquidCrystal.h>
LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);
float val = 0;// define the variable as value=0
void setup()
{
lcd.begin(16, 2);
pinMode(PA7, INPUT);// input
}
void loop()
{
val = analogRead(PA7);
U1 = (val * 3.3) / 4.096;
if (val > maxValue)
{
maxValue = val;
}
//+++++++++++++++++++
if (val > maxValue1)
{
maxValue1 = val;
}
if (val > maxValue2)
{
maxValue2 = val;
}
if (val > maxValue3)
{
maxValue3 = val;
}
if (val > maxValue4)
{
maxValue4 = val;
}
if (val > maxValue5)
{
maxValue5 = val;
}
//++++++++++++++++++
/*
lcd.setCursor(0, 0);
lcd.print(U1, 0); //Print the number of val on the LCD
lcd.setCursor(5, 0);
lcd.print(maxValue, 0);
*/
//+++++++++++++++++++++++++
lcd.setCursor(0, 0);
lcd.print(maxValue1, 0);
lcd.setCursor(5, 0);
lcd.print(maxValue2, 0);
lcd.setCursor(9, 0);
lcd.print(maxValue3, 0);
lcd.setCursor(0, 1);
lcd.print(maxValue4, 0);
lcd.setCursor(5, 1);
lcd.print(maxValue5, 0);
//+++++++++++++++++++++++++
delay(200); //Wait for 200ms
}