Map function returning incorrect value
i trying create program control variable speed refrigeration compressor based on temperature. part stuck @ on map function. should return value between 0 , 255 instead 1147 comes out. meant happen when temperature 5 degrees c compressor @ full speed , when @ 0 degrees compressor runs @ slowest speed.
and here output
temp c: 19.06
1147
code: [select]
float tempc = sensors.gettempc(deviceaddress);
serial.print("temp c: ");
serial.print(tempc);
compspeed = map(tempc, 1, 5, 0, 255);
serial.println();
serial.print (compspeed);
and here output
temp c: 19.06
1147
you tell map range of tempc 0 5. give 19.
skip map. need if conditions tell outside of 0-5 degc.
skip map. need if conditions tell outside of 0-5 degc.
Arduino Forum > Using Arduino > Programming Questions > Map function returning incorrect value
arduino
Comments
Post a Comment