User manual
102 lcd.print("% ");
103
104 lcd.setCursor(0, 1);
105
106 percent = map(percent, 0, 100, 0, 80);
107
108 c1 = percent / 5;
109 c2 = percent % 5;
110
111 for(i = 0; i < c1; ++i)
112 lcd.write(byte(5));
113
114 lcd.write(c2);
115
116 for(i = 0; i < 16 – (c1 + (c2 ? 1 : 0)); ++i)
117 lcd.write(byte(0));
118 }
119
120 void setup()
121 {
122 analogWrite(9,200);
123
124 lcd.createChar(0, MyChar0);
125 lcd.createChar(1, MyChar1);
126 lcd.createChar(2, MyChar2);
127 lcd.createChar(3, MyChar3);
128 lcd.createChar(4, MyChar4);
129 lcd.createChar(5, MyChar5);
130
131 lcd.begin(16, 2);
132 }
133
134 void loop()
135 {
136 int raw_adc = adc_AVG(0);
137 draw_bargraph(100 – raw_adc);
138 delay(20);
139 }
When you have set up the circuit and transferred the example code
to the Arduino™-board, a value near 100 % will be displayed on
the LCD in bright environments, and the bar of the bar chart will
fill the lower row of the LCD almost completely.
If you darken the photo transistor now, the value will reduce
to near zero. Look at the circuit more precisely. The photo
transistor is connected to the 10-kΩ-resistance at the col-
lector, which is connected to +5 V, and to GND (ground) at the
emitter. The analogue input 0 of the Arduino™-PCB is connected