hy guyz,i'm working on digital voltmeter and ammeter (130V and 40A,on lcd) using atmega328.
it is working well on proteus.but not worknig on verroboard,it shows the constant voltage and current i.e, 130V and 40A(max. limits).it does not detect the adc voltage.But it is working well on arduino uno board. ![]()
This is my code.
#include <LiquidCrystal.h>
LiquidCrystal lcd(7,8,9,10,11,12);
int analogInput = 0;
int analogInput1 = 1;
float vout = 0.0,vout1 = 0.0,vin = 0.0,vin1 = 0.0;
float vinnew=0.0;
float R1 = 680000.0;
float R2 = 27000.0;
float R3=100000.0;
float R4=100000.0;
float value = 0.0;
float value1 = 0.0;
void setup() {
lcd.begin(20,4);
pinMode(analogInput, INPUT);
pinMode(analogInput1, INPUT);
lcd.setCursor(0,2);
lcd.print("voltmeter");
delay(100);
}
void loop() {
lcd.setCursor(0,0);
lcd.print(" V A");
value = analogRead(analogInput);
value1 = analogRead(analogInput1);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
vout1 = (value1 * 5.0) / 1024.0;
vin1 = vout1 / (R4/(R3+R4));
lcd.setCursor(0, 1);
if (vin<0.1)
{
vin=0.00;
}
vinnew=4*vin1;
if (vinnew<0.1)
vinnew=0.0;
lcd.print(vin);
lcd.setCursor(8, 1);
lcd.print(vinnew);
delay(500);
}