Hallo Experten, ich habe einen kleinen Sketch, der auch läuft:
#include <LedControl.h>
// MAX7219 Pins: DIN, CLK, CS
LedControl lc = LedControl(12, 11, 10, 1);
const int ptPin = A1;
const float Rref = 1000.0; // Referenzwiderstand 1kΩ
const float R0 = 1000.0; // PT1000 bei 0°C
const float alpha = 0.00385; // Temperaturkoeffizient
void setup() {
lc.shutdown(0, false);
lc.setIntensity(0, 5);
lc.clearDisplay(0);
}
void loop() {
int adcValue = analogRead(ptPin);
float voltage = adcValue * (5.0 / 1023.0);
float Rpt = (voltage * Rref) / (5.0 - voltage);
float tempC = (Rpt - R0) / (R0 * alpha);
displayNumber((int)tempC );
delay(500);
}
void displayNumber(int num) {
lc.clearDisplay(0);
lc.setDigit(0, 6, abs(num) % 10 , false); //true = Dezimalpunkt
lc.setDigit(0, 7, (abs(num) / 10) % 10 , false); // 7 = ganz links
if (num < 0) lc.setChar(0, 2, '-', false);
}
Dazu ist mir nicht klar, woher der Wert für die Variable num kommt. Gemessen habe ich den Wert adcValue. Wie entsteht daraus num?
Danke. Joachim

