Select Page

Difficulty Level = 1 [What’s this?]

The Digit Shield makes it trivial to add a numeric display to your project. I’ve used my simple LM34 temperature sensor in many projects, but this is the simplest. Here’s the LM34 sensor connected to analog input pin 0 on the Arduino, with the temperature displayed on the Digit Shield.







The code reads the sensor value, translates to millivolts, and then translates to a temperature (the sensor outputs 10mV per Fahrenheit degree). The Digit Shield library makes it so easy to display the temperature. Here’s the entire Arduino sketch:

#include 

float AREF = 1.1;

void setup() {
  analogReference(INTERNAL);
  DigitShield.begin();
  DigitShield.setPrecision(1);
}

void loop() {
  delay(500);
  int r = analogRead(0);
  int mv = (((float)r/1023.0) * AREF) * 1000.0;
  double t = mv / 10.0;
  DigitShield.setValue(t);
}