NodeMCU + JSN-SR04T + TM1637

TM1637 na 3.3V svítí velice slabě

 

#include <HCSR04.h>
#include "SevenSegmentTM1637.h"


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

const byte PIN_CLK = D7;   // define CLK pin (any digital pin)
const byte PIN_DIO = D8;   // define DIO pin (any digital pin)
SevenSegmentTM1637    display(PIN_CLK, PIN_DIO);

int distance;

void setup()
{
  Serial.begin(115200);
  Serial.print("Meric-vzdalenosti");
  display.begin();            // initializes the display
  display.setBacklight(100);  // set the brightness to 100 %
  display.print("INIT");      // display INIT on the 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();                      // clear the display
      display.print(distance);                // print SUCC for success
      delay(1000);
  }
  delay(100);
}

 

Napsat komentář