Vše na 3.3V
displej SCL = D1 a SDA = D2
#include <HCSR04.h> #include <Wire.h> #include <ACROBOTIC_SSD1306.h> HCSR04 hc(D6, D5); // Initialize Pin D6, D5 int distance; void setup() { Serial.begin(115200); Serial.print("Meric-vzdalenosti"); Wire.begin(); oled.init(); // Initialze SSD1306 OLED display oled.clearDisplay(); // Clear screen oled.putString("INIT"); 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 oled.clearDisplay(); oled.setTextXY(0,0); // Set cursor position, start of line 0 oled.putString(String(distance)); delay(1000); } delay(100); }