NodeMCU + JSN-SR04T + OLED BIG FONT

Jiná knihovna která má 3 velikosti písma, umí vykreslovat i obrazce, atd…

 

https://github.com/ThingPulse/esp8266-oled-ssd1306

esp8266-oled-ssd1306-master

 

 

#include <HCSR04.h>
#include <Wire.h>
//#include <ACROBOTIC_SSD1306.h>
#include "SSD1306.h"


#define SDA D2
#define SCL D1

SSD1306 display(0x3c, SDA, SCL);

HCSR04 hc(D6, D5); // Initialize Pin D6, D5



int distance;

void setup()
{
  Serial.begin(115200);
  Serial.print("Meric-vzdalenosti");
  Wire.begin(); 
  display.init();
  display.flipScreenVertically();
  display.setFont(ArialMT_Plain_10);
  display.drawString(0, 0, "init");

  display.display();



  delay(200);                // wait 1000 ms
}


void loop()
{


  distance = hc.dist();      /*je to int takže bez desetin*/

  if (distance>0) {   
      Serial.println(distance); // Print in centimeters the value from the sensor
      
      display.clear();
      display.drawCircle(5,5,5);
      display.setFont(ArialMT_Plain_24);
      display.drawString(0, 25, String(distance));
      display.display();
      delay(100);      
      display.fillCircle(5,5,5); 
      display.display();
      
       
      delay(1000);
  }
  delay(100);
}



 

Napsat komentář