#include <LCD4Bit.h>extern "C" { #include <stdio.h>}LCD4Bit lcd = LCD4Bit(4); int ledPin = 13; //Hurr, our LED Pin.int value = LOW; // previous value of the LEDlong previousMillis = 0; // will store last time LED was updated//some messages to display on the LCDint inter = 1000;int val[2];int lastVal[2];int buttonPin[2] = {7,6};int inc = 10;void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); //we'll use the debug LED to output a heartbeat pinMode(buttonPin[0],INPUT); pinMode(buttonPin[1],INPUT); lcd.init(); //lcd.commandWrite(0x0F); lcd.printIn("Please note:");lcd.cursorTo(2,0); lcd.printIn("Due to the amount"); lcd.cursorTo(3,0); lcd.printIn("of time the LCD"); lcd.cursorTo(4,0); lcd.printIn("takes to refresh"); delay(5000); lcd.clear(); lcd.printIn("this app may slow"); lcd.cursorTo(2,0); lcd.printIn("down the LED's"); lcd.cursorTo(3,0); lcd.printIn("blinking when you"); lcd.cursorTo(4,0); lcd.printIn("press a button."); delay(5000); lcd.clear(); lcd.cursorTo(1,0); updtMsg();}void updtMsg(){ char interP[10]; sprintf(interP,"%d",inter); lcd.printIn("Button1: "); lcd.printIn(" "); lcd.cursorTo(1,9); if (val[0] == HIGH) { lcd.printIn("HIGH"); }else{ lcd.printIn("LOW"); } lcd.cursorTo(2,0); lcd.printIn("Button2: "); lcd.printIn(" "); lcd.cursorTo(2,9); if (val[1] == HIGH) { lcd.printIn("HIGH"); }else{ lcd.printIn("LOW"); } lcd.cursorTo(3,0); lcd.printIn("Interval: "); lcd.printIn(" "); lcd.cursorTo(3,10); lcd.printIn(interP); lcd.cursorTo(4,0); //lcd.printIn("LCD Status: "); lcd.printIn(" "); lcd.cursorTo(4,12); //if (value == HIGH) { lcd.printIn("HIGH"); }else{ lcd.printIn("LOW"); } lcd.printIn("By: Julian Moore"); lcd.cursorTo(1,0);}void loop() { val[0] = digitalRead(buttonPin[0]); val[1] = digitalRead(buttonPin[1]); if (lastVal[0] != val[0]) //DOWN Button (1) { lastVal[0] = val[0]; updtMsg(); if (val[0] == LOW) { inter = inter + inc; updtMsg(); } } if (lastVal[1] != val[1]) //UP Button (2) { lastVal[1] = val[1]; updtMsg(); if (val[1] == LOW) { inter = inter - inc; updtMsg(); } } if (millis() - previousMillis > inter) { previousMillis = millis(); // remember the last time we blinked the LED // if the LED is off turn it on and vice-versa. if (value == LOW) value = HIGH; else value = LOW; //Serial.print("Switching: ");Serial.print(value);Serial.print("\n"); //updtMsg(); digitalWrite(ledPin, value); }}