# ANALOG INPUT range is 0.00 - 1.00

**URL:** <https://forum.xod.io/t/analog-input-range-is-0-00-1-00/41>\
**Category:** Uncategorized\
**Created:** [July 2, 2017, 1:01pm UTC](https://forum.xod.io/t/analog-input-range-is-0-00-1-00/41 "2017-07-02T13:01:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tguneysu](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/tguneysu/32/17_2.png) [@tguneysu](https://forum.xod.io/u/tguneysu)\
**Post date:** [July 2, 2017, 1:01pm UTC](https://forum.xod.io/t/analog-input-range-is-0-00-1-00/41/1 "2017-07-02T13:01:54Z")

</div>

ARDUINO sensors and ADC inputs produce a 0-1023 range of numbers.  
XOD is not so.

Not only that, when I route the output of an analog port into a PWM block, it only works like on/off switch at the half-point value. Meaning, if I turn up the pot from 0 to 50% value nothing happens, and at 51% value the signal is switched to on on the corresponding port. There is no gradual incremental increase of the signal like it is in Arduino.

I tried setting the value field of the Analog Input to various numbers but it does not make a difference.

ALSO: I was trying to dump the analog values to the console with the CONSOLE-LOG block. It did not produce any output in XOD or in CONSOLE window of the developer tools. But if I open the Arduino Serial Monitor, it displays all the values as I change the POT on the analog port.

Is there a way to seeing values in XOD ? Or are we not supposed to see it there?

It makes sense that the values are seen in Arduino Serial Monitor from the connectivity point of view, but it is a pain to go back and forth. It also confuses the issue of where is the development done - XOD or IDE?

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [July 3, 2017, 8:49am UTC](https://forum.xod.io/t/analog-input-range-is-0-00-1-00/41/2 "2017-07-03T08:49:56Z")

</div>

> ARDUINO sensors and ADC inputs produce a 0-1023 range of numbers.  
> XOD is not so.

This is by-design. The context-free range from 0.0 to 1.0 seems like a more natural choice. In Arduino you have to map between 0-1023 (0-4095 on some boards) and 0-255 quite often, and the ranges themselves could look quite odd if you’re not familiar with bits and bytes.

0-1 range should make many nodes directly compatible without any mappings

> [@tguneysu](#):
>
> Not only that, when I route the output of an analog port into a PWM block, it only works like on/off switch at the half-point value. Meaning, if I turn up the pot from 0 to 50% value nothing happens, and at 51% value the signal is switched to on on the corresponding port. There is no gradual incremental increase of the signal like it is in Arduino.
> 
> I tried setting the value field of the Analog Input to various numbers but it does not make a difference.

I’ve tried a simple patch:

![](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/27e8713038bf993c42d137bcfc29d15d0bc6eb06.png)

With a potentiometer on analog input A0 (`14`) and a LED on `9`.

When I rotate the knob, LED’s brightness smoothly changes. Can you confirm that it does not work for you?

> [@tguneysu](#):
>
> I was trying to dump the analog values to the console with the CONSOLE-LOG block. It did not produce any output in XOD or in CONSOLE window of the developer tools. But if I open the Arduino Serial Monitor, it displays all the values as I change the POT on the analog port.

Yes, it is incomplete. The big idea is to have _watches_. The kind of nodes that once connected to a particular pin shows the value in real-time and effectively are small serial monitors that show only values associated with them.

---

<div class="post-metadata">

**Author:** ![tguneysu](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/tguneysu/32/17_2.png) [@tguneysu](https://forum.xod.io/u/tguneysu)\
**Post date:** [July 3, 2017, 5:54pm UTC](https://forum.xod.io/t/analog-input-range-is-0-00-1-00/41/3 "2017-07-03T17:54:26Z")

</div>

> With a potentiometer on analog input A0 (14) and a LED on 9.

> When I rotate the knob, LED’s brightness smoothly changes. Can you confirm that it does not work for you?

What is the port numbering method in XOD ?  
Digitals first 0-n, followed by Analogs n+1…n+ ?

Thx.

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [July 3, 2017, 7:26pm UTC](https://forum.xod.io/t/analog-input-range-is-0-00-1-00/41/4 "2017-07-03T19:26:38Z")

</div>

That’s right:

- Digital 0 → 0
- Digital 1 → 1
- Digital 2 → 2
- …
- Digital 12 → 12
- Digital 13 → 13
- Analog A0 → 14
- Analog A1 → 15
- Analog A2 → 16
- Analog A3 → 17
- Analog A4 → 18
- Analog A5 → 19

The reason why you can’t yet simply write A3 is that XOD expects a number and `A3` isn’t a number. That would be fixed.

Also, note that you should use a pin marked with a tilde (~) on the board to get PWM signals work properly.

---

<div class="post-metadata">

**Author:** ![articcynda](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/articcynda/32/13_2.png) [@articcynda](https://forum.xod.io/u/articcynda)\
**Post date:** [July 3, 2017, 8:53pm UTC](https://forum.xod.io/t/analog-input-range-is-0-00-1-00/41/5 "2017-07-03T20:53:06Z")

</div>

Trying to use PWM on an Arduino pin that isn’t connected to the PWM controller indeed causes it to flip from high to low at the 50% treshold.

May I suggest, if technically possible, to replace the textboxes with dropdown lists or comboboxes instead? Then unexperienced users can simply select a pin from the list, and problems like trying to use PWM on a pin that doesn’t support it would be evaded since those pins aren’t available from the list (but, if you wanted to do it anyway, you could still type it into the combobox).

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [July 4, 2017, 3:27pm UTC](https://forum.xod.io/t/analog-input-range-is-0-00-1-00/41/6 "2017-07-04T15:27:22Z")

</div>

Yes, this is our TODO.

---

<div class="post-metadata">

**Author:** ![joshuaacnewman](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/joshuaacnewman/32/33_2.png) [@joshuaacnewman](https://forum.xod.io/u/joshuaacnewman)\
**Post date:** [August 3, 2017, 5:46am UTC](https://forum.xod.io/t/analog-input-range-is-0-00-1-00/41/7 "2017-08-03T05:46:32Z")

</div>

What do you mean when you say,

> That would be fixed.

?

Do you mean you consider it a bug and it’s on your to-do list? Or do you mean that we have to fix our code/xod to reflect this new numbering scheme? Or what?

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [August 3, 2017, 9:54am UTC](https://forum.xod.io/t/analog-input-range-is-0-00-1-00/41/8 "2017-08-03T09:54:10Z")

</div>

> [@joshuaacnewman](#):
>
> Do you mean you consider it a bug and it’s on your to-do list?

Yes. At some point of time hardware, ports will get their own type different from current generic “Number”. It will allow setting values like `A0` directly in Inspector.
