Go Down

Topic: A/D converter with 0 to 1023 binary output (Read 1 time) previous topic - next topic


Hi, well, the title say all. I´m trying to do an A/D converter, but i want that the digital conversion be in the digitals pins 2 to 11 in the binary form

For example the minor value 0 is showed in these array of pins

if is the max value (1023) is showed


i know that the analog pins read 0 to 5V and the max value is 1023=5V

The case is, I want the analog reading be displayed in binary form in an array of 10-bit in the digital pins

any suggestion??????

PD: sorry for my bad english.... :P


Aug 23, 2011, 04:12 am Last Edit: Aug 23, 2011, 04:56 am by InvalidApple Reason: 1
just some pseudo for you:

if analogue value is above 1000000000:
  minus 1000000000 and turn on pin 11...

if analogue value is above 0100000000:
  minus 0100000000 and turn on pin 10...

... ect


Or to go backwards of that logic (assuming low bit first on pin 2 and high bit on pin 11)

for (int i=0, i<10, i++)
digitalWrite(i+2, analog_value & 1);   //bitwise and to 1 so we only take the lowest bit
analog_value = analog_value >> 1;    //shift it one to the right to put the next bit in the low bit.

Ad hoc, ad loc, and quid pro quo.  So little time - so much to know!  ~Jeremy Hillary Boob Ph.D



well, maybe i did´n explain very well

i know the A/D of the arduino converts 0 to 5V  in the range 0-1023, were 1023 is the max value...

or 4.88 mV for each value of convertion  (1024x0.00488=5V aprox)

if i have 3.5V in the analog input.... 3.5/4.88mV=717.21....

internally in the A/D i have 717.21...or 717....and i want show  this value in an array...


internally in the A/D i have 717.21...or 717

You have 717 internally.

It is still not clear what you mean by
i want show  this value in an array.

An array of what? Do you mean display? The answers given match the question asked.


Aug 23, 2011, 06:21 am Last Edit: Aug 23, 2011, 08:32 am by retrolefty Reason: 1
and i want show  this value in an array...

i want that the digital conversion be in the digital pins 2 to 11 in the binary form

What you wish to do is not hard.

Read the analog pin into a variable, then test each bit value of value and turn on or off the digital pin associated with that bit:

Code: [Select]
int value = analogRead(A0);
        for (int i=0; i <= 9; i++)
           if (bitRead(value,i))


Be sure to use current limiting series resistors with each of the LEDs.



I did some thing almost exactly the same as this a while back. The only difference was that I divided it by 4 and then wrote its value to 8 LEDs. It was pretty cool actually. But the bitRead function is the way to go for sure

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131