Hello,
I am a beginner with Arduino and I wanted to make a simple temperature display.
The sensor I use is a DS18B20.
In my prototype, the sensors worked good (I can check it with the serial monitor) but it doesn't work together with my 4 digit 7 segment LED display. With the software I only get the number -127 on my display (and also in the serial monitor).
HERE IS THE SOFTWARE:
#include <SevenSeg.h>
#include <Wire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 // Data DS18B20 on pin 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
int temp;
SevenSeg disp(15,3,4,5,6,7,8);
const int numOfDigits=4;
int digitPins[numOfDigits]={9,10,11,12};
int temp;
void setup() {
sensors.begin();
disp.setDigitPins(numOfDigits,digitPins);
//Control brightness (values 0-100);
disp.setDutyCycle(80);
disp.setTimer(2);
disp.startTimer();
Serial.begin(9600);
}
void loop() {
sensors.requestTemperatures();
temp = sensors.getTempCByIndex(0);
delay(1000);
Serial.println(sensors.getTempCByIndex(0));
disp.write(temp,0);
}
ISR(TIMER2_COMPA_vect){
disp.interruptAction();
}
When I switch off the timer in the setup:
//disp.setTimer(2);
//disp.startTimer();
and the part in the loop:
//ISR(TIMER2_COMPA_vect){
//disp.interruptAction();
//}
I can see the temperature with the LED display, but it flickers (I see the temperature, but the number is flashing very quick, most of the time the display is off).
I cant find what I do wrong? Is there some one to give advice?
See also attachment (ino file) .
Thanks for help,
Greeting, Guido
TestTemperatuurSevenSegmentLED.ino (845 Bytes)