Enviro PHAT single analog output syntax


Hullo me hearties.

Could anyone suggest the correct python syntax for pulling a single analog value, rather than all 4 values?

Can’t find it anywhere in the documentation.

Ta muchly



there are several ways you can do it, depending on what your script requires one may be better than the other:

In [1]: import envirophat

In [2]: envirophat.analog.read(0)
Out[2]: 0.618

In [3]: envirophat.analog.read_all()[0]
Out[3]: 0.628

the first method addresses the input directly, the second accesses index 0 in the array made up of all the values.

the second is what is used in the ‘all.py’ example, if you are curious as to what context it may prove useful.

Hope that helps.