Arduino - What is [./n.]? -


i making dimmer in arduino using potentiometer , found website told me convert analog values (0-1023) voltage (0-255). line converted divided 255 1023 , multiplied potentiometer reading. line ledwrite = (255./1023.) * potread;. tried write ledwrite = (255/1023) * potread;, periods, code wouldn't run.

what's ./n.?

the assignment

ledwrite = (255./1023.) * potread; 

is equivalent to

ledwrite = (255.0 / 1023.0) * potread; 

that is, trailing zero can omitted.

on arduino uno, constants interpreted doubles , result of division double value.

at present time, note double , float have same precision (4 bytes) on arduino boards, exception of arduino due.


in following line

ledwrite = (255/1023) * potread; 

the 2 numeric literals interpreted integers , division operation 1 among integers, in case returns 0 since 255 smaller |1023|.