Alright so I've been trying to update/change the number on the display during a loop, but nothing really happens. It doesnt change/update, the value is always exactly same.

#include <TM1637Display.h>

#define led_display 1
#define led_display_scnd 3 

int analogPin = A0;
int moisture;
int percentage;

int map_low = 686;
int map_high = 350;

TM1637Display display(led_display_scnd, led_display);

void setup() {
  pinMode (led_display, OUTPUT);

  digitalWrite(led_display, HIGH);


void loop() {
  moisture = analogRead(analogPin);
  Serial.print("Raw: ");

  int sensorValue = analogRead(A0);
  percentage = 100-((sensorValue-110)*100L/(1023-110));

  Serial.print(" | Percentage: ");

  display.showNumberDec(moisture); // updating the value

  • Does the value of "Raw:" change on the terminal? That's the number you are trying to display. – JRobert Jul 28 '19 at 16:38
  • Yeah it does. Here an example from whats In terminal 18:39:41.242 -> Raw: 1018 | Percentage: 1% 18:39:43.294 -> Raw: 956 | Percentage: 8% 18:39:45.353 -> Raw: 955 | Percentage: 8% – Tomislav Tomi Nikolic Jul 28 '19 at 16:39
  • That leaves a compiler bug that affects either the library or your call to it, a bug in the library (such as its I2C implementation), or your wiring to the pins being used by the library for I2C (from least likely to most likely, if I had to guess). Double check your wiring against the pins you chose for the display. Also it looks like one of those pins is pin-1, which is the hardware UART's serial transmitter. Try a another pin for the display; you may just be trying to back-drive the UART. – JRobert Jul 28 '19 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.