ANALOG INPUT range is 0.00 - 1.00

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?

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

I’ve tried a simple patch:

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?

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.

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.

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.

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).

Yes, this is our TODO.

1 Like

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?

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.