Good Afternoon,
I am currently looking into how to display an output onto a TM1637.
Let's say that I have an output I would like to display of 22.44 what would be the best way to achieve it?
Currently I am using the TM1637Display.h library for it.
I am supplying the 4 digit number using float.
Any help would be much appreciated. I will paste all of my code down below:
#include <math.h>
#include <TM1637Display.h>
const int thermistor_output = A1;
#define CLK 10
#define DIO 9
TM1637Display display = TM1637Display(CLK, DIO);
void setup() {
Serial.begin(9600); /* Define baud rate for serial communication */
}
void loop() {
display.setBrightness(7);
int thermistor_adc_val;
double output_voltage, thermistor_resistance, therm_res_ln, temperature;
thermistor_adc_val = analogRead(thermistor_output);
output_voltage = ( (thermistor_adc_val * 5.0) / 1023.0 );
thermistor_resistance = ( ( 5 * ( 10.0 / output_voltage ) ) - 10 ); /* Resistance in kilo ohms */
thermistor_resistance = thermistor_resistance * 1000 ; /* Resistance in ohms */
therm_res_ln = log(thermistor_resistance);
/* Steinhart-Hart Thermistor Equation: */
/* Temperature in Kelvin = 1 / (A + B[ln(R)] + C[ln(R)]^3) */
/* where A = 0.001129148, B = 0.000234125 and C = 8.76741*10^-8 */
temperature = ( 1 / ( 0.001129148 + ( 0.000234125 * therm_res_ln ) + ( 0.0000000876741 * therm_res_ln * therm_res_ln * therm_res_ln ) ) ); /* Temperature in Kelvin */
temperature = temperature - 273.15; /* Temperature in degree Celsius */
Serial.print("Temperature in degree Celsius = ");
Serial.print(temperature);
Serial.print("\t\t");
Serial.print("Resistance in ohms = ");
Serial.print(thermistor_resistance);
Serial.print("\n\n");
// Print 1234 with the center colon:
float i = temperature;
Serial.println(i);
display.showNumberDec(i); // THIS IS WHERE I WOULD LIKE IT TO DISPLAY THE 4 DIGITS
//display.showNumberDec(temperature, true, 4);
delay(1000);
}