//display
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
//wifi
#include <WiFi.h>
//realtime
#include<NTPClient.h>
#include<WiFiUdp.h>
// define oled parameters
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3c
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
//buttons
int buttonG = 2;
int buttonR = 4;
WiFiDUP ntpUDP;
void setup() {
// display inisialization
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;); // Don't proceed, loop forever for loop runs forever
}
display.display();
delay(1000);
display.clearDisplay();
pinMode(buttonG, INPUT);
pinMode(buttonR, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
int x = digitalRead(buttonG);
int y = digitalRead(buttonR);
if (x == LOW) {
display.clearDisplay();
print_line("RANIL", 1, 1, 2);
delay(1000);
} else if (y == LOW) {
display.clearDisplay();
print_line("ANURA", 1, 1, 2);
delay(1000);
} else {
display.clearDisplay();
print_line("VOTE?", 1, 1, 2);
}
}
void print_line(String text, int column, int row, int text_size) {
display.setTextSize(text_size);
display.setTextColor(WHITE);
display.setCursor(column, row);
display.println(text);
display.display();
}