Digital Thermometer
Digital Thermometer Project မှာ TI (Texas Instruments) က ထုတ်တဲ့ LM35 ကို သုံးပြီး လေထဲက အပူချိန်ကိုဖတ်ပါမယ်။ ထို့နောက် LED ၆ လုံးက အပူချိန် ၂၀ ဒီဂရီ စင်တီဂရိတ်ထက်ကျော်ရင် မီးလင်းလာမှာပါ။
Circuit Diagram
LED များ၊ LM25 နဲ့ Arduino UNO တို့ ချိတ်ဆက်ပုံကိုအောက်ပါအတိုင်းတွေ့ရမှာပါ။
အလုပ်လုပ်ပုံ
LM35 IC မှ အပူချိန်ကို Arduino UNO ရဲ့ Analog Pin A0 ကို သုံးပြီးဖတ်ယူပါ့မယ်။ analogRead() function ကို သုံးပြီး ဖတ်မှာပါ။
ဖတ်လို့ရတဲ့ တန်ဖိုူက Digital Value (0~1024) ဖြစ်ပါတယ်။ 1024 Digital Value က 5V နဲ့ ညီမျှပါတယ်။ ဒီတော့ 1 Digital value က 5/1024 ပါ။ ရလာတဲ့ တန်ဖိုးကို ဘယ်လိုပြောင်းလဲ Coding မှာ ကြည့်နိုင်ပါတယ်။
Coding
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
/* Sensing the Temperature with the LM35 Fritzing.org This script will output the sensed temperature of the LM35 from 20 to 32°C by LEDs. inspired by ladyada http://www.ladyada.net/learn/sensors/tmp36.html pscmpf http://pscmpf.blogspot.com/2008/12/arduino-lm35-sensor.html */ float temperature; // အပူချိန်ကို သိမ်းထားဖို့ int sensorPin = 0; // Sensor Pin A0 ကို သုံးထားပါတယ်။ int startTemp=20; // LED မီးက 20 degC ထက်ကျော်မှ လင်းစေချင်တဲ့ အတွက် StartTemp ကို သတ်မှတ်ထားတာပါ။ void setup() { Serial.begin(9600); // Serial Communication ကို အစပြုပါ။ for (int i=2;i<8; i++){ // LED Pin တွေက Pin 2 ကနေ Pin 7 အထိ pinMode(i,OUTPUT); // OUTPUT အနေနဲ့ ကြေငြာပါမယ်။ } } void loop() { temperature = analogRead(sensorPin); // LM35 IC မှ အပူချိန်ကို ဖတ် temperature = temperature*5*100/1024; // °C ပြောင်း for (int i=0;i<8; i++){ if (temperature>((i*2)+startTemp)){ // "starttemp + (LED number*2)" ထက် အပူချိန်မြင့်ရင် digitalWrite(i,HIGH); // LED မီးလင်းပေးပါ။ } else { digitalWrite(i,LOW); // နိမ့်သွားရင်တော့ LED မီး ပြန်မှိတ်ပေးပါ။ } } Serial.print(temperature); Serial.println(" °C"); // အပူချိန်ကို serial monitor မှ တဆင့် PC ကို ပို့ပေးပါ။ delay(500); // 500 ms စောင့်ပြီး နောက် တကြိမ် အပူချိန် ပြန်တိုင်းမယ်။ } |