So I understand that the voltage coming in from the pin is mapped to a value between 0 and 1023. Why this range? what is the source of this range?

Why this range?

Because it is a ten bit analogue to digital converter.

And 2^10=1024

hammy:

And 2^10=1024

Nope.

2^10 == 8.

2^{10} == 1024.

Try googling “2^10”

Mine sez 1024

That's odd - mine does `[sup][/sup]`

either as text, or from the toolbar.

hammy:

And 2^10=1024

AWOL:

Nope.

2^10 == 8.2

^{10}== 1024.

```
byte x1 = 2; //00000010
byte x2 = 10; //00001010
x1 ^= x2;
Serial.print(x1, BIN); //00001000 = 8 = (2 EOR 10) = (00000010 EOR 00001010)
```

li16:

So I understand that the voltage coming in from the pin is mapped to a value between 0 and 1023. Why this range? what is the source of this range?

Hope, the following figure might help you understanding the mechanism for analog voltage (0 - 5V) to undergo transformation/mapped into 0 -1023 (0x0000 - 0x03FF).

Figure-1: ADC Module of Atmega328P MCU

**1.** When input voltage is 0V, all bits of ADC assume 0s (B9 - B0 = 00 00000000 = 0x0000 = 0)

**2.** When input voltage is 5V, all bits of ADC assume 1s (B9 - B0 = 11 11111111 = 0x03FF = 1023)

Edit: Diagram of Fig-1 is edited to contain V_{REF} as 5V and not 1.1V. The revision is made in respect of Post#8.

GolamMostafa:

Hope, the following figure might help you understanding the mechanism for analog voltage (0 - V_{REF}0 to undergo transformation/mapped into 0 -1023 (0x0000 - 0x03FF).

Does that seem likely, really?

AWOL:

Does that seem likely, really?

The diagram of Post#7 has been edited to comply with the text description of V_{REF} = 5V. ++++++++++ again. Ooops, does not take!

GolamMostafa:

`byte x1 = 2; //00000010`

byte x2 = 10; //00001010

x1 ^= x2;

Serial.print(x1, BIN); //00001000 = 8 = (2 EOR 10) = (00000010 EOR 00001010)

JUNK! The ^ operator in C means "exclusive or" (XOR), in mathematics it means "power of". It is two different things and 2^10 = 1024!

GolamMostafa:

Hope, the following figure might help you understanding the mechanism for analog voltage (0 - 5V) to undergo transformation/mapped into 0 -1023 (0x0000 - 0x03FF).

Do you honestly thing that someone who is asking such a fundamental question is going to understand that diagram?

I am having trouble understanding its relevance.

Danois90:

JUNK! The ^ operator in C means “exclusive or” (XOR), in mathematics it means “power of”. It is two different things and 2^10 = 1024!

In mathematics?

Really?

Or in BASIC?

Danois90:

JUNK! The ^ operator in C means “exclusive or” (XOR), in mathematics it means “power of”. It is two different things and 2^10 = 1024!

Should I remind you that we are playing here (in a predominantly) Programming Forum; so, the **^** performs a **bit-wise exclusive (XOR/EOR** operation. 2^10 == 8 is the pseudo code of: x = 00000010 XOR 00001010 = 00001000 = 8.

Danois90:

in mathematics it means "power of"

Not according to actual mathmeticians...

http://mathworld.wolfram.com/Hat.html

Grumpy_Mike:

Do you honestly thing that someone who is asking such a fundamental question is going to understand that diagram?I am having trouble understanding its relevance.

As a poster, I have tried to pour whatever I have thinking that it may add some value to someone? We may recall that the words/sounds that we utter are ultimately linked with some kind of objects; the said diagram is an object that resembles 'ADC and 0- 1023'.

I love these absolutely meaningless discussions that have nothing to do with the OP's post. For what it's worth, according to the ISO 31-11 standard defining mathematical signs and symbols, the only use of the caret (upper case 6, '^') is in describing a conjunction in set theory.

Beyond that, it is also stated that it 'can be used as a surrogate symbol for superscript and exponentiation where superscript is not readily usable' (people actually get paid to write like that).

As a poster, I have tried to pour whatever I have thinking that it may add some value to someone?

Not sure what the question mark is about there.

But what you actually do more often than not is pile in so much information that is not relevant in an attempt to help that you just end up confusing and frightening a beginner into thinking things are a lot more complex than they are. Can you please try and resist this temptation.

Grumpy_Mike:

Not sure what the question mark is about there.

But what you actually do more often than not is pile in so much information that is not relevant in an attempt to help that you just end up confusing and frightening a beginner into thinking things are a lot more complex than they are. Can you please try and resist this temptation.

Not sure what the question mark is about there.

But what you (do), actually do more often than not, is pile in so much information that is not relevant in an attempt to help; (that) you just end up confusing and frightening a beginner (with) (into thinking) things (that) are a lot more complex than they are. Can you please try and resist this temptation(.)(?)

C’mon my fellow pendants, using ^ to denote “to the power of” is pretty well accepted in math and science shorthand. If I type 2^10 into my Wolfram Alpha app, it returns 1024. So who ya gonna believe, Wolfram or Wolfram?