https://learn.sparkfun.com/tutorials/sp … troduction
Hello,
I´d like to know if it´s possible to get floats into the 14segment display. ( example : temperature sensor readings)
I tried several mods of this code on a ESP8266 but it doesn´t work correctly.
What i get on the display is 645.0
Can anyone help me? :roll: :?:
#include <Wire.h>
#include <SparkFun_Alphanumeric_Display.h>
HT16K33 display;
float t = 64.5 ;
void setup()
{
Serial.begin(9600);
Serial.println("SparkFun Qwiic Alphanumeric - Example 1: Print String");
Wire.begin(); //Join I2C bus
if (display.begin() == false)
{
Serial.println("Device did not acknowledge! Freezing.");
while (1);
}
Serial.println("Display acknowledged.");
}
void loop(){
display.print("TEMP");
delay(2000);
display.print(t);
delay(3000);
display.print("289.1");
delay(2000);
Serial.println(t);
}
What is displayed when you set
float t = 6.45 ;
When I write
float t = 6.45 ;
I´m getting 654. :?
sorry the picture is very large
I´m getting 654. :?
Not according to the picture you posted.
It is not clear from the documentation whether the display actually supports floating point numbers, and there is no clear example of actually printing one. There is this weird and rather unhelpful comment in the library example code:
//You can print colons and decimals
//NOTE: they can only go in the character position determined by the layout of the display
display.print("12:3.4");
So, maybe you have to format numbers such that the decimal is always after the 3rd digit.
Try this code, as the code you posted has extra features that complicate the issue.
#include <Wire.h>
#include <SparkFun_Alphanumeric_Display.h>
HT16K33 display;
float t = 6.45 ;
void setup()
{
Serial.begin(9600);
Serial.println("SparkFun Qwiic Alphanumeric - Example 1: Print String");
Wire.begin(); //Join I2C bus
if (display.begin() == false)
{
Serial.println("Device did not acknowledge! Freezing.");
while (1);
}
Serial.println("Display acknowledged.");
display.print(t);
}
void loop(){}