ok so I am trying to make a volume knob with Arduino and python, Arduino handles the rotary encoder and python handles the volume change. I am using the library pycaw to change the volume. I am stuck because I have a number, 1-100 coming from Arduino but i need a number -96 to 0 for pycaw. Does anyone know of a library that can help me? Thanks!
Asked
Active
Viewed 76 times
0
-
2See https://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio – jarmod Jun 05 '21 at 15:26
-
Does this answer your question? https://stackoverflow.com/questions/44338698/p5-js-map-function-in-python – fsimonjetz Jun 05 '21 at 15:27
-
this is the code i put in OldRange = 100 NewRange = 96 NewValue = (((dat - 0) * NewRange) / OldRange) + -96 but i get the error: TypeError: unsupported operand type(s) for -: 'str' and 'int' – Andrew Jun 05 '21 at 15:55