Analog Temperature Sensor
using an LM393 Low Power Low Offset Voltage Dual Comparator
hardware
- Arduino Uno R3 board
- Analog Temperature Sensor
wire
Analog Temperature Sensor | Arduino Uno |
---|---|
AO | A0 |
DO | 7 |
VCC | 5v |
GND | GND |
code
/****************
* Analog Temperature sensor
using an LM393 Low Power Low Offset Voltage Dual Comparator
*****************/
const int digitalPin = 7;
int analogPin = A0;
const int ledPin = 13;
boolean Dstate = 0;
int Astate = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(digitalPin, INPUT);
Serial.begin(9600);
}
void loop() {
Astate = analogRead(analogPin);
Dstate = digitalRead(digitalPin);
Serial.print("DO: ");
Serial.println(Dstate);
Serial.print("AO: ");
Serial.println(Astate);
// if pushbutton is pressed, turn led on
if (Dstate == HIGH)
{
digitalWrite(ledPin, LOW);
}
else
{
digitalWrite(ledPin, HIGH);
}
delay(1000);
}
Page Source