integer round up or down?

Dear all,

Description:
AnalogRead(A0) reads the value from that specific analog pin. Arduino boards contain a multichannel, 10-bit analog to digital converter. This means that it will map input voltages between 0 and the operating voltage(5V) into integer values between 0 and 1023. On an Arduino UNO, for example, this yields a resolution between readings of: 5 volts / 1024 units or, 0.0049 volts (4.9 mV) per unit.

Question:
What is the output when you meassure 4.8mV in analogRead(A0)?
I think the output will be 0 but i am not sure.

Moved your topic to it's current location as it is more suitable.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Well... Section 23.1 of the [u]ATmega datasheet[/u] says absolute accuracy of +/- 2 bits with linearity of +/- 1/2 bit.

And see section 23.6.3 ADC Accuracy Definitions

igorv1234:
Dear all,

Description:
AnalogRead(A0) reads the value from that specific analog pin. Arduino boards contain a multichannel, 10-bit analog to digital converter. This means that it will map input voltages between 0 and the operating voltage(5V) into integer values between 0 and 1023. On an Arduino UNO, for example, this yields a resolution between readings of: 5 volts / 1024 units or, 0.0049 volts (4.9 mV) per unit.

Question:
What is the output when you meassure 4.8mV in analogRead(A0)?
I think the output will be 0 but i am not sure.

Why not experiment to find out? A few voltage dividers strung together can give you well defined small voltages.

If you problem requires this sort of accuracy, I suggest you need a higher-precision ADC.

DVDdoug:
Well... Section 23.1 of the [u]ATmega datasheet[/u] says absolute accuracy of +/- 2 bits with linearity of +/- 1/2 bit.

And see section 23.6.3 ADC Accuracy Definitions

Which in turn means that 4.8mV could be 0~3 on analog read.

The ADC does not round - that implies that it knows the exact value, and then rounds it to 10 bits. It does not. Those 10 bits are the limit of it's knowledge. What this means in practice is that the low bit can change even when the applied voltage is constant. Atmel has an application note on oversampling and decimation to improve ADC accuracy; it might be a good read.