I'm using the following library to drive a 4 digit, 7 segment LED display:
http://playground.arduino.cc/Main/SevenSegmentLibrary
The display is showing the temperature which it gets from a DS18B20 temperature sensor. Since the LED display constantly needs to be refreshed, when the code runs to get the current temperature, the display temporarily turns off because the LEDs are not being refreshed. The code I am using is below. Is there anyway to prevent the LED display from turning off while the temperature request code runs?
#include <SevSeg.h>
#include <OneWire.h>
#include <DallasTemperature.h>
SevSeg sevseg;
unsigned long timer; // the timer
unsigned long INTERVAL = 30000; // the repeat interval (30 seconds)
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
byte numDigits = 4;
byte digitPins[] = {A2, A3, A4, A5};
byte segmentPins[] = {8, 10, 6, 4, 3, 9, 7, 5};
sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);
sevseg.setBrightness(90);
// Get the initial temperature and show it on the LED display
sensors.begin();
sensors.requestTemperatures();
sevseg.setNumber(sensors.getTempCByIndex(0), 1);
timer = millis(); // start timer
}
void loop() {
if ((millis()-timer) > INTERVAL) {
// Reset the timer and get/display the current temperature
timer += INTERVAL;
sensors.requestTemperatures();
sevseg.setNumber(sensors.getTempCByIndex(0), 1);
}
sevseg.refreshDisplay(); // Must run repeatedly to refresh the LED display
}