but i can t make work the analog read of arduino nano
i made a simple voltemeter but it always gives me the result of 54,9 volt thata is the maximum
and also the simple analogread command gives 1023 but from my multimeter i read just 1,3 volt maximum
so the sketch works well on arduino mega but the problem heppens when i compile the sketch on Arduino Nano
#include <LiquidCrystal.h> // include the library code:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //initialize the library with the numbers of interface pins
// variables for input pin and control LED
int analogInput = 0;
float vout = 0.0;
float vin = 00.0;
float R1 = 100000.0; // resistance of R1 (100k)
float R2 = 10000.0; // resistance of R2 (10k)
int value = 0; // variable to store the value
void setup(){
pinMode(analogInput, INPUT); // declaration of pin modes
lcd.begin(16, 2); // set up the LCD’s number of columns and rows:
lcd.print(“Vin=”);
}
void loop(){
value = analogRead(analogInput); // read the value on analog input
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
// print result to lcd display
lcd.setCursor(4, 0);
lcd.print(vin);
lcd.print(“V”);
delay(500); // sleep…
}
I see references to R1 and R2 in your code, which makes me think you are using a voltage divider. Please post a schematic of how you have things hooked up.
If the same code works with MEGA but not nano, then it's connection problem, not code. Post your setup picture. I use plenty of nano boards. It's not the board.