Untuk mencoba tutorial ini,modul yang di butuhkan :
1.Arduino Uno
2.LCD Keypad Shield
BACA JUGA ARTIKEL MENARIK :
- Cara Merancang High Current Motor Driver H-bridge Modul IBT-2 Menggunakan arduino
- Cara mendeteksi Sensor Suhu dan Kelembapan Menggunakan Arduino DHT22 Source Code Gratis
- Cara Buat Program 8 Digit 7 Segment Menggunakan SPI MAX7219 dengan Arduino
![]() |
DIAGRAM
ALOKASI PIN ARDUINO
CONTOH PROGRAM
/*******************************************************
Program : LCD KARAKTER KEYPAD SHIELD 16X2
Chip : Arduino Uno
Date : 25/06/2015
Created : Mark Bramwell
Modified : Lab-elektronika Team
email : elektronikajakarta@gmail.com
Sumber : ramanewss.blogspot.com
********************************************************/
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int tombollcd = 0;
int bacatombol = 0;
#define tombolright 0
#define tombolup 1
#define tomboldown 2
#define tombolleft 3
#define tombolselect 4
#define tombolnone 5
int read_LCD_buttons()
{
bacatombol = analogRead(0);
if (bacatombol > 1000) return tombolnone;
if (bacatombol < 50) return tombolright;
if (bacatombol < 250) return tombolup;
if (bacatombol < 450) return tomboldown;
if (bacatombol < 650) return tombolleft;
if (bacatombol < 850) return tombolselect;
return tombolnone;
}
void setup()
{
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("TEKAN TOMBOL");
}
void loop()
{
lcd.setCursor(0,1);
tombollcd = read_LCD_buttons();
switch (tombollcd)
{
case tombolright:
{
lcd.print("RIGHT ");
break;
}
case tombolleft:
{
lcd.print("LEFT ");
break;
}
case tombolup:
{
lcd.print("UP ");
break;
}
case tomboldown:
{
lcd.print("DOWN ");
break;
}
case tombolselect:
{
lcd.print("SELECT");
break;
}
case tombolnone:
{
lcd.print("NONE ");
break;
}
}
}
PENJELASAN PROGRAM
- Panggil library lcd untuk arduino
#include <LiquidCrystal.h>
- Inisialisasi pin arduino yg di gunakan
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
- Mendefinisikan nilai variabel
int tombollcd = 0; int bacatombol = 0; #define tombolright 0 #define tombolup 1 #define tomboldown 2 #define tombolleft 3 #define tombolselect 4 #define tombolnone 5
- Fungsi baca tombol dengan adc
int read_LCD_buttons()
{
bacatombol = analogRead(0);
if (bacatombol > 1000) return tombolnone;
if (bacatombol < 50) return tombolright;
if (bacatombol < 250) return tombolup;
if (bacatombol < 450) return tomboldown;
if (bacatombol < 650) return tombolleft;
if (bacatombol < 850) return tombolselect;
return tombolnone;
}
- Tampilkan karakter ke lcd
lcd.print("TEKAN TOMBOL");
- Set posisi kolom dan baris
lcd.setCursor(0,0);
lcd.setCursor(0,1);
- Baca tombol ditekan
tombollcd = read_LCD_buttons();



0 Response to "CARA MEMPROGRAM LCD KARAKTER KEYPAD SHIELD 16X2 DENGAN ARDUINO BERUPA SOURCE CODE "
Post a Comment