Acquiring 8 bit analog data instead of 12 bit in ASCII format

Hello,
I am using Arduino Uno board, I am using its adc to acquire the analog signal. I have two questions.

1- How to get 8 bit data instead of 12 bit from Arduino Uno, I have tried analogReadResolution(8) but its giving compiling error.

2- I want to read the data in ASCII format since i have to send it serially.

So please guide me how can I read 8 bit data from adc in ASCII format.
Regards

Shift the data right 4 bits? Is that what you mean?

int foo = analogRead (0);
foo >>= 4;  // now has an 8-bit result.

That would discard the 4 low-order bits.

How to get 8 bit data instead of 12 bit from Arduino Uno, I have tried analogReadResolution(8) but its giving compiling error.

Next time:

  • Post your code.
  • Post the error message.

How to use this forum

Thanks alot Nick, Why can't I use the analogReadResolution(8) in Uno board?

Hello,

I have tested the program, but it has a little error which i have resolved but want to inform others who may follow my post.

The number we mention after foo>>= 4; defines the number of bits we want to reject, since we only want to reject 2 bits in a 10 bit resolution adc to get the 8 bit data, we will replace 4 by 2.

Regards

Meanwhile if you want to send data as ASCII to the serial port, just use the command Serial.write(data);

learntodo: Thanks alot Nick, Why can't I use the analogReadResolution(8) in Uno board?

Because it isn't implemented.

https://www.arduino.cc/en/Reference/AnalogReadResolution

analogReadResolution() is an extension of the Analog API for the Arduino Due and Zero.