Hello and good morning everyone, i'm having a bit of a trouble to get a small "timer" to work, and since i'm a bit new to c++ (and programming in general) i'm having a hard time figuring it out. So, i'm using a 4 digits led-display with a temperature sensor (lm35 sensor). I got the sensor to work with the led-display, but it's hard to read because how often the temperature slightly changes. So i decided to use a small "timer" to read the temperature once in a while and here it appeared the problem, i cant get the "timer" to work.
Here is my code
#include "SevSeg.h"
float tempC;
int tempPin = 0;
float time1;
SevSeg sevseg; //Initiate a seven segment controller object
void setup() {
Serial.begin(9600);
byte numDigits = 4;
byte digitPins[] = {2, 3, 4, 5};
byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};
bool resistorsOnSegments = false;
byte hardwareConfig = COMMON_CATHODE;
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
sevseg.setBrightness(90);
}
void loop() {
time1 + 1;
if (time1 == 100); {
tempC = analogRead(tempPin);
tempC = (5.0 * tempC * 100.0)/1024.0;
sevseg.setNumber(tempC, 1);
time1 = 0;
}
sevseg.refreshDisplay(); // Must run repeatedly
Serial.println(tempC);
Serial.println(time1);
}
Any help is appreciated.
PD: Sorry for bad spelling issues/wrong words