Buat Termometer LCD Arduino dengan Sensor Suhu LM35/36
Komponen dan Perlengkapan
Arduino UNO
×
1
Sensor Suhu
×
1
Adafruit Standard LCD - 16x2 Putih pada Biru
×
1
Kabel jumper (generik)
×
1
Papanciuk (generik)
×
1
Tentang Proyek Ini
Halo, semuanya! Saya akan menunjukkan cara membuat termometer LCD dengan Arduino UNO dan sensor suhu analog LM35/36 dengan kabel jumper dan papan roti.
Proyek ini sangat baik bagi pemula Arduino, tidak memerlukan keterampilan rekayasa atau pemrograman khusus dan akan memakan waktu kurang dari 10 menit untuk membangunnya, setelah Anda memiliki semua bagian tentunya.
Langkah 1: Mengumpulkan Bagian
Ini adalah bagian yang Anda butuhkan untuk membuat termometer:
1x Papan Arduino UNO
1x Papanciuk
1x Tampilan LCD 16x2
1x Sensor suhu analog LM35 atau LM36
1x Potensiometer 10k - untuk menyesuaikan kecerahan tampilan*
19x Kabel jumper - untuk menghubungkan semuanya
Mereka juga tersedia di Kit Starter Resmi Arduino yang dapat Anda pesan dari halaman resmi Arduino di sini. Juga Anda dapat membeli secara terpisah dari toko berikut: Adafruit, SparkFun, Aliexpress, Banggood, dll.
*Jika Anda tidak memiliki potensiometer 10k, Anda dapat menggunakan 50k seperti saya!
Langkah 2: Membangun Termometer
Dengan mengikuti skematik Fritzing di atas, colokkan LCD di papan roti dan kemudian hubungkan ke papan Arduino dengan kabel jumper. Setelah itu colokkan potensiometer dan sensor di papan roti, hubungkan pin kiri dan kanan potensiometer ke ground dan +5V dan pin tengah ke tampilan LCD.
Kemudian hubungkan sensor ke ground dan ke +5V dan ke Arduino tetapi berhati-hatilah, karena jika Anda menghubungkannya dengan salah sensor akan panas hingga 280+ C(540 F) dan mungkin rusak. Setelah Anda menghubungkan semuanya lanjutkan ke langkah berikutnya.
Langkah 3: Memprogram Arduino
Untuk membuatnya berfungsi Anda harus menggunakan salah satu dari dua kode di bawah ini. Unggah ke Arduino Anda menggunakan lingkungan pengembangan terintegrasi, singkatnya IDE, yang dapat Anda unduh dari halaman resmi Arduino dan Anda selesai!
Jika Anda tidak melihat apa-apa di LCD atau Anda melihat persegi panjang, putar potensiometer searah jarum jam/berlawanan arah jarum jam sampai Anda melihat huruf jelas. Sekarang Anda memiliki termometer dan Anda dapat mengukur suhu udara di sekitar Anda, di dalam rumah atau di luar.
Kode pertama adalah dari Gaige Kerns, dan dapat digunakan untuk membaca dari LM36 atau LM35. Terima kasih Gaige! Juga periksa proyek termometer baru saya di sini!
<p>// include the library code #include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize our variables int sensorPin = 0; int tempC, tempF; void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); } void loop() { tempC = get_temperature(sensorPin); tempF = celsius_to_fahrenheit(tempC); lcd.setCursor(0,0); lcd.print(tempF); lcd.print(" "); lcd.print((char)223); lcd.print("F"); delay(200); } int get_temperature(int pin) { // We need to tell the function which pin the sensor is hooked up to. We're using // the variable pin for that above // Read the value on that pin int temperature = analogRead(pin); // Calculate the temperature based on the reading and send that value back float voltage = temperature * 5.0; voltage = voltage / 1024.0; return ((voltage - 0.5) * 100); } int celsius_to_fahrenheit(int temp) { return (temp * 9 / 5) + 32; }</p> #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Digital pins to which you connect the LCD const int inPin = 0; // A0 is where you connect the sensor void setup() { lcd.begin(16,2); } void loop() { int value = analogRead(inPin); // read the value from the sensor lcd.setCursor(0,1); float millivolts = (value / 1024.0) * 5000; float celsius = millivolts / 10; lcd.clear(); lcd.setCursor(0,0); lcd.print(celsius); lcd.print("C"); lcd.setCursor(0,1); lcd.print((celsius * 9)/5 + 32); //turning the celsius into fahrehait lcd.print("F"); delay(1000); }
FJXZ51IHQAX1RR7.txt
Kode
Potongan kode #1
Potongan kode #2
Potongan kode #1Teks biasa
<p>// include the library code #include // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize our variables int sensorPin = 0; int tempC, tempF; void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); } void loop() { tempC = get_temperature(sensorPin); tempF = celsius_to_fahrenheit(tempC); lcd.setCursor(0,0); lcd.print(tempF); lcd.print(" "); lcd.print((char)223); lcd.print("F"); delay(200); } int get_temperature(int pin) { // We need to tell the function which pin the sensor is hooked up to. We're using // the variable pin for that above // Read the value on that pin int temperature = analogRead(pin); // Calculate the temperature based on the reading and send that value back float voltage = temperature * 5.0; voltage = voltage / 1024.0; return ((voltage - 0.5) * 100); } int celsius_to_fahrenheit(int temp) { return (temp * 9 / 5) + 32; }</p>
Potongan kode #2Teks biasa
#include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Digital pins to which you connect the LCD const int inPin = 0; // A0 is where you connect the sensor void setup() { lcd.begin(16,2); } void loop() { int value = analogRead(inPin); // read the value from the sensor lcd.setCursor(0,1); float millivolts = (value / 1024.0) * 5000; float celsius = millivolts / 10; lcd.clear(); lcd.setCursor(0,0); lcd.print(celsius); lcd.print("C"); lcd.setCursor(0,1); lcd.print((celsius * 9)/5 + 32); //turning the celsius into fahrehait lcd.print("F"); delay(1000); }