#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <gfxfont.h>
#include <Wire.h>
#include <Ticker.h> //Ticker Library
Ticker blinker;
#define LED 5 //On board LED
volatile int count = 0;
float WINDS = 0;
//#include <SPI.h>
#define ANALOG_PIN A0
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 OLED(SCREEN_WIDTH,SCREEN_HEIGHT,&Wire,OLED_RESET);
void changeState()
{
digitalWrite(LED, !(digitalRead(LED))); //Invert Current State of LED
count = 0;
}
void ICACHE_RAM_ATTR blink()
{
//read_state = HIGH;
count++;
Serial.println(count);
}
void setup() {
// put your setup code here, to run once:
OLED.begin(SSD1306_SWITCHCAPVCC, 0x3C);
Serial.begin(115200);
Serial.println("");
pinMode(LED,OUTPUT);
//Initialize Ticker every 0.5s
blinker.attach(10.0, changeState); //Use attach_ms if you need time in ms
attachInterrupt(18, blink, FALLING);
}
void loop() {
// put your main code here, to run repeatedly:
WINDS = count*0.66698368;
OLED.clearDisplay();
OLED.setTextColor(WHITE);
OLED.setCursor(5,20);
OLED.setTextSize(2);
OLED.print(WINDS);
OLED.print(" m/s");
// OLED.setCursor(35,20);
// OLED.setTextSize(2);
// OLED.println("Size2");
OLED.display();
}