#define outputA 7
#define outputB 8
int counter =0;
int aState;
int aLastState;
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
int battery = A1;
int readval;
int v1 = 0;
int j=8;
int y=0;
int p=4;
U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 10, /* data=*/ 11, /* CS=*/ 9, /* reset=*/ 16);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(battery, INPUT);
Serial.begin(9600);
u8g2.begin();
pinMode(battery, INPUT);
pinMode (outputA,INPUT);
pinMode (outputB,INPUT);
Serial.begin(9600);
aLastState = digitalRead(outputA);
}
void loop() {
// put your main code here, to run repeatedly
aState = digitalRead(outputA);
if (aState != aLastState){
if (digitalRead(outputB) != aState){
counter --;
}else{
counter ++;
}
Serial.print("Position: ");
Serial.println(counter);
}
aLastState = aState;
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
u8g2.drawStr(2, 13, "Info Screen");
u8g2.drawStr(2, 28, "Battery Settings"); // write something to the internal memory
u8g2.drawStr(2, 43, "Temp Settings");
u8g2.drawStr(2, 58, "Humidity Settings ");
u8g2.drawHLine(0, 0, 128);
u8g2.drawHLine(0, 16, 128);
u8g2.drawHLine(0, 31, 128);
u8g2.drawHLine(0, 46, 128);
u8g2.drawHLine(0, 63, 128);
u8g2.drawVLine(0, 0, 64);
u8g2.drawVLine(111, 0, 63);
u8g2.drawVLine(127, 0, 63);
u8g2.drawVLine(127, 0, 63);
u8g2.drawCircle(119, y, 5);
u8g2.drawCircle(119, y, 4);
u8g2.drawCircle(119, y, 3);
u8g2.drawCircle(119, y, 2);
u8g2.sendBuffer();
y=counter*7.5+8.;
}