I am reading values from a potentiometer that I can rotate to produce a range of numbers from 0-1023. I want to be able to display these numbers in terms of a horizontal bar graph on an LCD screen. The LCD screen is 20 blocks wide so the 0-1023 must be scaled down to 0-20. The character I want to use to produce the bar graph is a block that fills one entire block out of the 20 available. The bit pattern for this block is 0b11110001
.
block = 0b11110001;
BarGraph = ((DELVAL2/5115)*2000);
lcd_putxy(2,0,buf);
for (delay = 0; delay < 50000; delay++); // introduce a delay
sprintf(buf, "*", BarGraph);
lcd_putxy(2,0,buf);
I was hoping somebody could explain to me how to achieve this and the best method for scaling down my potentiometer values.