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.

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.


Arduino Forum > Using Arduino > Programming Questions > Map function returning incorrect value


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts