Arduino MEGA analog problem


hey, guys
i'm noob...
so problem designed arduino voltmeter using voltage divider.
firstly, ok measure voltage... thereafter, wanted try again,
and discovered value not accurate , 0 ( such v= 11.xxv) when didn't plug on it....
its supposed 0 if haven't plug on it... m wondering if arduino kind of broken of fried out......
plz me...

here code ....


int analoginput = 2;
float vout = 0.0;
float vin = 0.0;
float r1 = 50000.0;   
float r2 = 4400.0;     


int value = 0;

void setup(){
  serial.begin(9600);

  pinmode(analoginput, input);



}

void loop(){
  value = analogread(analoginput);

  vout = (value * 5.0) / 1024.0;
  vin = vout / (r2/(r1+r2)); 

  serial.print("vin=");
  serial.print(vout);



  delay(1000);
}



Arduino Forum > Using Arduino > Microcontrollers > Arduino MEGA analog problem


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial