0

I'm not sure if I am heading in the right direction with the map function, but...

I read an analog to digital converter. It returns a value from 0-255. I am trying to use the map function to map that AD number to 0-360. It is a Davis wind vane. For example, a reading of 127.2 should return a 180.

Some guidance please?

>>> vane=127.2
>>> direction = map(vane,0,255,0,36)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable
>>> 
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
creeser
  • 363
  • 1
  • 4
  • 11
  • That's not how you use `map`. From the Python docs https://docs.python.org/3/library/functions.html#map: "*Return an iterator that applies function to every item of iterable, yielding the results.*" – Gino Mempin Aug 06 '22 at 00:31
  • The accepted answer (https://stackoverflow.com/a/1969274/2745495) gets you exactly what you want without using any libraries. – Gino Mempin Aug 06 '22 at 00:36

0 Answers0