--> Project II - 16. Thermometer Digital Bar Graph menggunakan TFT LCD Touch Screen berbasis Arduino Uno | Tutorial arduino lengkap

Wednesday, August 2, 2017

Project II - 16. Thermometer Digital Bar Graph menggunakan TFT LCD Touch Screen berbasis Arduino Uno

| Wednesday, August 2, 2017
Thermometer Digital Bar Graph menggunakan TFT LCD Touch Screen



Sistem Kerja Alat

Arduino UNO membaca temperature dengan sensor suhu LM35 dan hasilnya ditampilkan di LCD Touchscreen berupa bargraph yang didesain seperti tabung termometer analog. Modul LCD yang digunakan adalah 2.4’’ TFT LCD Shield.

Kebutuhan Hardware
  • Sensor Suhu LM35
  • LCD 2.4’’ TFT SHIELD
  • Modul Arduino UNO
  • Power supply +9Volt

                                Image 1 source                                           Image 2 source

Diagram Blok

Schematic





Koneksi Arduino UNO dengan modul LCD TFT 2’4” tinggal dipasangkan ke pin header Arduino, seperti shield2 yang lain. Koneksi Arduino UNO dengan modul TFT LCD Shield


Koneksi Sensor LM35

Source Code/Sketch
#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 XGRAPH 50
#define YGRAPH 125
#define HGRAPH 135
#define WGRAPH 21 //LEBAR GRAPH HARUS GANJIL
#define LM35 A5
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
int newHeight;
int oldHeight = 0;
int heightDiff;
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(RED);
tft.setTextSize(2);
tft.setCursor(140, 195);
tft.print("Suhu:");
Serial.begin(9600);
tft.fillCircle(XGRAPH, YGRAPH, (WGRAPH/2), BLACK);
tft.fillRect((XGRAPH-(WGRAPH/2)), YGRAPH, WGRAPH, HGRAPH, BLACK);
tft.fillCircle(XGRAPH, (HGRAPH+YGRAPH), ((WGRAPH/2)+10), BLACK);
tft.fillCircle(XGRAPH, YGRAPH, (WGRAPH/2)-3, WHITE);
tft.fillRect((XGRAPH-(WGRAPH/2)+3), YGRAPH, (WGRAPH-6), HGRAPH, WHITE);
tft.fillCircle(XGRAPH, (HGRAPH+YGRAPH), ((WGRAPH/2)+7), WHITE);
tft.fillCircle((XGRAPH+WGRAPH), YGRAPH, 3, BLACK);
tft.setTextColor(BLACK);
tft.setTextSize(2);
tft.setCursor(((XGRAPH+WGRAPH)+8), (YGRAPH-5));
tft.print("100");
tft.setTextSize(1);
tft.print("0");
tft.setTextSize(2);
tft.print("C");
tft.fillCircle((XGRAPH+WGRAPH), ((YGRAPH+(HGRAPH/2))-(WGRAPH/2)), 3, BLACK);
tft.setTextColor(BLACK);
tft.setTextSize(2);
tft.setCursor(((XGRAPH+WGRAPH)+8), (((YGRAPH+(HGRAPH/2))-(WGRAPH/2)))-5);
tft.print("50");
tft.setTextSize(1);
tft.print("0");
tft.setTextSize(2);
tft.print("C");
tft.fillCircle((XGRAPH+WGRAPH), ((YGRAPH+HGRAPH)-((WGRAPH/2)+7)), 3, BLACK);
tft.setTextColor(BLACK);
tft.setTextSize(2);
tft.setCursor(((XGRAPH+WGRAPH)+8), (((YGRAPH+HGRAPH)-((WGRAPH/2)+7))-5));
tft.print("0");
tft.setTextSize(1);
tft.print("0");
tft.setTextSize(2);
tft.print("C");
//tft.fillCircle(175, 225, 26, RED);
tft.fillRect((XGRAPH-(WGRAPH/2)+5), YGRAPH, (WGRAPH-10), HGRAPH, RED);
tft.fillCircle(XGRAPH, (HGRAPH+YGRAPH), ((WGRAPH/2)+5), RED);
}
void loop(void) {
int suhu=(analogRead(LM35)*5)/10;
tft.setCursor(130, 220);
tft.setTextColor(RED, WHITE);
tft.setTextSize(4);
tft.print(suhu);
tft.setTextSize(2);
tft.print("0");
tft.setTextSize(4);
tft.print("C");
tft.fillRect(130, 255, 80, 4, RED);
if(suhu <= 100){
newHeight = map(suhu,0, 100, 0, (HGRAPH-(WGRAPH/2)));
heightDiff = oldHeight-newHeight; // only draw new part of bar graph for faster display
if (oldHeight != newHeight) tft.fillRect((XGRAPH-(WGRAPH/2)+5), YGRAPH+((HGRAPH-suhu)-((WGRAPH/2)+7)), (WGRAPH-10), HGRAPH-((HGRAPH-suhu)-((WGRAPH/2)+7)), RED);
tft.fillRect((XGRAPH-(WGRAPH/2)+5), YGRAPH, (WGRAPH-10), ((HGRAPH-suhu)-((WGRAPH/2)+7)), WHITE);
if (suhu==100)tft.fillCircle(XGRAPH, YGRAPH, (WGRAPH/2)-5, RED);
oldHeight=newHeight; // remember how high bar is
}
tft.fillCircle(XGRAPH, (HGRAPH+YGRAPH), ((WGRAPH/2)+5), RED);
delay(300);
}


Jalannya Alat 

  1. Jika menggunakan 2.4’’ TFT LCD SHILED Anda bisa menambahkan pin koneksi pada pin A5 Arduino dengan pin deret. Sedangkan powernya (+5V dan GND) Anda juga bisa beri konektor untuk power supply sensor LM35
  2. Pastikan library TFT LCD sudah terinstal.
  3. Upload program diatas.
  4. LCD langsung menampilkan suhu yang terbaca


Video Project II - 16. Thermometer Digital Bar Graph menggunakan TFT LCD Touch Screen berbasis Arduino Uno



KAMI MELAYANI JASA PEMBUATAN HARDWARE ATAU SOFTWARE BERBASIS ARDUINO

KONTAK KAMI 085743320570 (adi sanjaya)

Related Posts

1 comment:

  1. saya mempunyai tugas dengan proyek pembuatan alat ayang ada lcd tft dengan ukuran 3,5" namun tidak touch screen . permasalahannnya saya mencoba dengan coding seperti di web tidak bisa jalan hanya putih saja pada lcdnya. bahkan saya mencoba coding yang lain tetap tidak bisa jalan. kalau di kompail sampai upload berhasil semua tapi di layar lcd tidak berfungsi seperi yang diinginkan mohon arahannya

    ReplyDelete