Hi I’m using a TM1637 with a clock colon and have a pressure sensor connected to it. The serial reading without any pressure connections start with 0.23
I would like to get rid of the decimal and round off…
Hi I’m using a TM1637 with a clock colon and have a pressure sensor connected to it. The serial reading without any pressure connections start with 0.23
I would like to get rid of the decimal and round off…
round()?
Serial.println(x, 0);
.
Which TM1637 library are you using? --> link to the library you have included
Which display are you using? --> link to the product you have bought
How does your code look like? --> post your code
What do you currently see on the display? --> make a picture and post it.
What do you want to see on the display?
Hi
Which TM1637 library are you using? --> Robojax TM1637
Which display are you using? -->TM1637 display
How does your code look like? -->
#include "Wire.h" //allows communication over i2c devices
#include <Arduino.h>
#include <TM1637Display.h>
// Module 1 connection pins (Digital Pins)
#define CLK1 3
#define DIO1 2
// Module 2 connection pins (Digital Pins)
#define CLK2 5
#define DIO2 4
// The amount of time (in milliseconds) between tests
#define TEST_DELAY 1500
TM1637Display display1(CLK1, DIO1);// define dispaly 1 object
TM1637Display display2(CLK2, DIO2);// define dispaly 1 object
uint8_t data[] = { 0x0, 0x0, 0x0, 0x0 }; // all segments clear
////Vacuum Sensor////
int sensor=A1;
int valueSensor;
int value;
int pressure;
////End of connect///////
void setup()
/////////Start of setup//////////
{
////Display setup////
// Robojax.com two or more TM1637 Display 20181029
display1.setBrightness(0x0f);// set brightness of dispaly 1
display2.setBrightness(0x0f);// set brightness of dispaly 1
display1.setSegments(data);// fill display 1 with whatever data[] array has
display2.setSegments(data);// // fill display 2 with whatever data[] array has
// Robojax.com two or more TM1637 Display 20181029
pinMode(sensor,INPUT);
Serial.begin(9600);
}
void loop()
{
////Display loop settings////
uint8_t data[] = { 0x0, 0x0, 0x0, 0x0 };
display1.setSegments(data);
delay(100);
display1.showNumberDec(pressure, true, 2, 0);
delay(TEST_DELAY);
//display1.showNumberDecEx(pressure, 64, false); /////////To activate the colon
display2.setSegments(data);// fill(clear) display with data[] array
display2.showNumberDec(34, true, 1,1);
delay(TEST_DELAY);// wait for TEST_DELAY miliseconds
//////Oil Pressure sensor///////
int sensorVal=analogRead(A0);
Serial.print("Sensor Value: ");
Serial.print(sensorVal);
float voltage = (sensorVal*5.0)/1024.0;
Serial.print("Volts: ");
Serial.print(voltage);
float pressure_pascal = (3.0*((float)voltage-0.47))*1000000.0;
float pressure_bar = pressure_pascal/10e5;
Serial.print("Pressure = ");
Serial.print(pressure_bar);
Serial.println("bars, 0");
Serial.print("Pressure = ");
delay(100);
}// loop end
What do you currently see on the display? --> "00"
What do you want to see on the display? example 0.30
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.