From a DHT sensor, I’m reading the ambient temperature and my goal is to display the temperature on a quadruple 7-segment display, ending with the letter C for Celsius degrees.
I receive the temperature from the sensor, convert the amount into an array, for example, if it is 19 degrees it would be [1,9], and each number goes to the corresponding display, in the example the 1 would be on display 2 and the 9 on display 3.
I need all digits to be displayed simultaneously; currently they are shown one by one on the corresponding display.
The numbers are represented in this way
void eight() {
digitalWrite(A, HIGH);
digitalWrite(B, HIGH);
digitalWrite(C, HIGH);
digitalWrite(F, HIGH);
digitalWrite(E, HIGH);
digitalWrite(D, HIGH);
digitalWrite(G, HIGH);
}
And this is the code
void loop() {
// Display the digits on the 7-segment displays
for (int i = 0; i < numDigits; ++i) {
switch (digits[i]) {
case 0:
c();
break;
case 1:
one();
break;
case 2:
two();
break;
case 3:
three();
break;
case 4:
four();
break;
case 5:
five();
break;
case 6:
six();
break;
case 7:
seven();
break;
case 8:
eight();
break;
case 9:
nine();
break;
}
// Display the current digit on the corresponding display
switch (i) {
case 0:
turnOnDisplay2();
break;
case 1:
turnOnDisplay3();
break;
}
// Wait briefly before moving to the next digit
delay(1000);
Serial.println(roundedTemperature);
}
// Display the letter 'C' on the fourth display
c();
turnOnDisplay4();
delay(1000);
}
And each display is turned on in this way, for example, this one is to turn on the second:
void turnOnDisplay2() {
digitalWrite(digit1, HIGH);
digitalWrite(digit2, LOW);
digitalWrite(digit3, HIGH);
digitalWrite(digit4, HIGH);
}
Daniela_02 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.