input - Arduino Converting AnalogInput(0-1024) to a 1-10 scale -


i'm new @ coding , i'm trying make meter 1-10 scale using analog inputs 0-1024. i'd reverse analog inputs. analog input 1024 0 in scale , analog input 0 10 in scale. sorry if easy code make started coding. you!

you should able use map function achieve want.

try following:

int val = analogread(0); int newval = map(val, 0, 1023, 10, 0); 

the first 2 numbers range of input value , second pair of numbers range want input mapped to.

have @ arduino reference map function.

note: don't have arduino on hand can't double check works.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -