Arduino Uno will read ADC Data from LM35 temperature sensor, and then it will be processed in order to be displayed on the LCD as temperature data.
Hardware Requirement
- LCD 2,4’’ TFT Shield with Touch Screen Module
- Arduino UNO
- LM35 Temperature Sensor
- Power supply +5 Volt
Block diagram
Schematic
Arduino - LCD 2.4" TFT Wiring
LCD 2.4" TFT Module is compatible with Arduino Uno, so you just plug in to the top of Arduino with All of pin connected, Like image below.
#include <Adafruit_GFX.h>
#include <Adafruit_TFTLCD.h>
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define YP A3
#define XM A2
#define YM 9
#define XP 8
#define LM35 A5
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
void setup(void) {
tft.reset();
uint16_t identifier = tft.readID();
if(identifier==0x0101)identifier=0x9341;
tft.begin(identifier);
tft.fillScreen(BLACK);
tft.drawRect(10, 10, 220, 75, YELLOW);
tft.fillRect(15, 15, 210, 65, BLUE);
tft.drawRect(10, 90, 220, 220, WHITE);
tft.fillRect(15, 95, 210, 210, WHITE);
tft.setTextColor(YELLOW, BLUE);
tft.setTextSize(3);
tft.setCursor(22, 20);
tft.print("Thermometer");
tft.setCursor(60, 50);
tft.print("Digital");
tft.setTextColor(BLUE, WHITE);
tft.setTextSize(3);
tft.setCursor(90, 130);
tft.print("Suhu");
}
void loop(void) {
int suhu=(analogRead(LM35)*5)/10;
tft.setCursor(40, 180);
tft.setTextColor(BLUE, WHITE);
tft.setTextSize(8);
tft.print(suhu);
tft.setTextSize(4);
tft.print("0");
tft.setTextSize(8);
tft.print("C");
delay(1000);
}
#include <Adafruit_TFTLCD.h>
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define YP A3
#define XM A2
#define YM 9
#define XP 8
#define LM35 A5
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
void setup(void) {
tft.reset();
uint16_t identifier = tft.readID();
if(identifier==0x0101)identifier=0x9341;
tft.begin(identifier);
tft.fillScreen(BLACK);
tft.drawRect(10, 10, 220, 75, YELLOW);
tft.fillRect(15, 15, 210, 65, BLUE);
tft.drawRect(10, 90, 220, 220, WHITE);
tft.fillRect(15, 95, 210, 210, WHITE);
tft.setTextColor(YELLOW, BLUE);
tft.setTextSize(3);
tft.setCursor(22, 20);
tft.print("Thermometer");
tft.setCursor(60, 50);
tft.print("Digital");
tft.setTextColor(BLUE, WHITE);
tft.setTextSize(3);
tft.setCursor(90, 130);
tft.print("Suhu");
}
void loop(void) {
int suhu=(analogRead(LM35)*5)/10;
tft.setCursor(40, 180);
tft.setTextColor(BLUE, WHITE);
tft.setTextSize(8);
tft.print(suhu);
tft.setTextSize(4);
tft.print("0");
tft.setTextSize(8);
tft.print("C");
delay(1000);
}
How it Works
1. Connect the Arduino with Peripherals needed
2. Plug in the Power Source on the device
3. Compile and upload the script program above to your arduino
4. Make sure the TFT LCD library is installed.
5. LCD will shown temperature for real time depend by your room temperature
Video for Project I - 18. Digital Thermometer using LCD Touch Screen (Arduino Based)
Download the required file.
hola amigo soy nuevo y estoy probando pero des pues de cargar el código correcto pero la pantalla no aparece nada. ayuda porfavor.
ReplyDelete