Files
2014-07-26 10:13:31 +10:00

29 lines
821 B
C++

#include <MicroView.h> // include MicroView library
int buttonPin = A0; // push button pin
int buttonState = 0; // variable to store the pushbutton status
void setup() {
uView.begin(); // start MicroView
uView.clear(PAGE); // clear page
pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input
digitalWrite(buttonPin,HIGH); // set Internal pull-up
}
void loop() {
buttonState = digitalRead(buttonPin); // read the state of the pushbutton value
// check if the pushbutton is pressed.
// if it is not pressed, the buttonState is HIGH:
if (buttonState == HIGH) {
uView.setCursor(0,0); // set cursor at 0,0
uView.print("OFF"); // print OFF
uView.display();
}
else {
uView.setCursor(0,0);
uView.print("ON ");
uView.display();
}
}