/* Demo of LCD and button shield. For details, see: http://hblok.net http://hblok.net/blog/posts/tag/LCD This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { pinMode(10, OUTPUT); // for backlight adjustment lcd.begin(16, 2); lcd.print("Hello World!"); } int button_value; int light = 100; void loop() { lcd.setCursor(0, 1); lcd.print(millis()/1000); button_value = analogRead(A0); if (button_value == 132) light = min(light + 1, 255); if (button_value == 306) light = max(light - 1, 0); analogWrite(10, light); String tmp = " "; tmp += light; tmp += " "; tmp += button_value; tmp += " "; // erase previous digits lcd.setCursor(4, 1); lcd.print(tmp); }