-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPushbuttonCounter.ino
More file actions
36 lines (29 loc) · 889 Bytes
/
PushbuttonCounter.ino
File metadata and controls
36 lines (29 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <MicroView.h>
int inPin = 2; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
int lastVal = 0;
int pushCount = 0;
void setup()
{
uView.begin(); // init and start MicroView
uView.clear(PAGE); // erase the memory buffer, when next uView.display() is called, the OLED will be cleared.
pinMode(inPin, INPUT); // declare pushbutton as input
}
void loop()
{
uView.setFontType(1); // set font type 1
uView.setCursor(11,0); // points cursor to x=11 y=0
uView.print("Hello");
uView.setCursor(11,16); // points cursor to x=11 y=16
//uView.print("World");
val = digitalRead(inPin); // read input value
if (val != lastVal) { // check if the input has changed
lastVal = val;
if (lastVal) {
pushCount += 1;
uView.print(pushCount);
}
}
uView.display();
//delay(100);
}