Hi there,
I'm using two tm1637 7segment 4 digit displays to display the temperatures of two ds18b20 sensors.
I have been using the bremme tm1637 library due to the ease of using LCD.Print style commands.
I can get the displays to show whole number temps fine using
display1.print(tempC0, 0);
However I'm trying to get it to show '24.2' for example as the temp but ive tried
display1.print(tempC0, 1); which the lcd.print library documentation states, but it just ends up showing '_4' instead?
Any ideas? My whole code is below. Need to figure out switching the decimal on as well.
#include <OneWire.h>
#include <DallasTemperature.h>
#include "SevenSegmentTM1637.h"
#include "SevenSegmentExtended.h"
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
//7Segment stuff
//1st Display
const byte PIN_CLK = 3; // define CLK pin (any digital pin)
const byte PIN_DIO = 4; // define DIO pin (any digital pin)
SevenSegmentExtended display1(PIN_CLK, PIN_DIO);
//2nd Display
const byte PIN_CLK1 = 5; // define CLK pin (any digital pin)
const byte PIN_DIO1 = 6; // define DIO pin (any digital pin)
SevenSegmentExtended display2(PIN_CLK1, PIN_DIO1);
float tempC0 = 0;
float tempC1 = 0;
void setup() {
//7 Segment Setup stuff
//Display1
display1.begin(); // initializes the display
display1.setBacklight(100); // set the brightness to 100 %
display1.clear();
delay(1000); // wait 1000 ms
//Display2
display2.begin(); // initializes the display
display2.setBacklight(100); // set the brightness to 100 %
display2.clear();
delay(1000);
sensors.begin();
pinMode(3, OUTPUT);
analogWrite(3, 0);
Serial.begin(9600);
}
void loop() {
sensors.requestTemperatures();
tempC0 = sensors.getTempCByIndex(0);
tempC1 = sensors.getTempCByIndex(1);
delay(1000);
Serial.println(tempC0);
Serial.println(tempC1);
//display1.setColonOn(true);
display1.print(tempC0, 0);
display2.print(tempC1, 0);
delay(1000);
}