Помогите вывести десятые числа на дисплей ТМ1637
- Войдите на сайт для отправки комментариев
Ср, 28/08/2019 - 00:04
#include <Arduino.h>
#include <Wire.h>
#include <TM1637Display.h>
// Module connection pins (Digital Pins)
#define pinClk 5
#define pinDIO 4
TM1637Display display(pinClk,pinDIO);
int flowPin = 2; //This is the input pin on the Arduino
double flowRate; //This is the value we intend to calculate.
volatile int count; //This integer needs to be set as volatile to ensure it updates correctly during the interrupt process.
void Flow()
{
count++; //Every time this function is called, increment “count” by 1
}
void setup() {
// put your setup code here, to run once:
pinMode(flowPin, INPUT); //Sets the pin as an input
attachInterrupt(0, Flow, RISING); //Configures interrupt 0 (pin 2 on the Arduino Uno) to run the function “Flow”
Serial.begin(9600); //Start Serial
}
void loop() {
display.setBrightness(0x0f);
// put your main code here, to run repeatedly:
count = 0; // Reset the counter so we start counting from 0 again
interrupts(); //Enables interrupts on the Arduino
delay (1000); //Wait 1 second
noInterrupts(); //Disable the interrupts on the Arduino
//Start the math
flowRate = (count * 3.60); //Take counted pulses in the last second and multiply by 2.25mL
flowRate = flowRate * 60; //Convert seconds to minutes, giving you mL / Minute
flowRate = flowRate / 100; //Convert mL to Liters, giving you Liters / Minute
Serial.println(flowRate); //Print the variable flowRate to Serial
display.showNumberDecEx(flowRate); //Display the Variable value;
}
Ребята добрый вечер. Новичок сосвсем в этой теме. Есть нужда в расходомере жидкости реального времени. Слепил я данное чудо. Но вот одна беда не могу никак понять как вывести десятые доли полученого расхода на дисплей. Целые пожалуйста, все работает. Десяты в терменале показывает.
Подскажите как правильно в коде это оформить.
умножаете число на десять и выводите так же, как до того выводили целое. А потом просто зажигаете десятичную точку в нужном месте.
Я уже думал об этом. Но никак не могу понять какой командой это сделать. Использую библиотеку tm1637display.h.
Я уже думал об этом. Но никак не могу понять какой командой это сделать.
у вас есть библиотека, откройте ее - там есть примеры и комментарии