38
In this example we will connect an LCD4884 Joystick shield to an Arduino, this is a useful reasonably low cost LCD for your projects
This shield provides a simple and effective all-in-one solution to interfacing with a project. Fitting tightly on top of Arduino UNO and DUEMILANOVE form microcontrollers and providing a high detail 48×84 graphic LCD screen and 5 action joystick, this shield is ideal for a wide range of bespoke projects.
The shield gives you access to all the remaining digital and analog ports that an Arduino can possibly provide and gives each its own VCC and GND. This is the typical required format that sensor modules are supplied in as can be seen in our range of sensor modules.
It is able to display in English, Chinese and even images. It also integrates a 5 DOF joystick. The shield has 6 Digital IO and 5 Analog IO on its face for easy prototyping.
Specs
- Power Supply: 5V
- SPI Interface (uses Arduino Digital Pin 2,3,4,5,6)
- One Reset button
- One 5 degree joystick (uses Arduino Analog Pin 0)
- Backlight control (Arduino Pin 7)
Code
The library I used is – http://www.mikroblog.net/wp-content/uploads/2018/02/LCD4884_Joystick_Shield_Demo.zip
[codesyntax lang=”cpp”]
#include <LCD4884.h> #define LCD_BACKLIGHT_PIN 7 int switchDelay = 100; int switchVoltage; void setup() { Serial.begin(9600); pinMode(LCD_BACKLIGHT_PIN, OUTPUT); lcd.LCD_init(); lcd.LCD_clear(); // blanks the display for (int a = 0; a < 6; a++) { lcd.LCD_write_string(0, a, "01234567980123", MENU_NORMAL); delay(1000); } delay(1000); lcd.LCD_clear(); // blanks the display } void loop() { lcd.LCD_write_string(1, 1, "Push a button", MENU_NORMAL); switchVoltage = analogRead(0); Serial.print("Switch analog value = "); Serial.println(switchVoltage); if (switchVoltage == 0) { lcd.LCD_write_string(2, 2, "LEFT ", MENU_NORMAL); } else if (switchVoltage > 0 && switchVoltage < 180) { lcd.LCD_write_string(2, 2, "PUSHED IN", MENU_NORMAL); delay(100); } else if (switchVoltage > 180 && switchVoltage < 400) { lcd.LCD_write_string(2, 2, "DOWN ", MENU_NORMAL); delay(100); } else if (switchVoltage > 400 && switchVoltage < 600) { lcd.LCD_write_string(2, 2, "RIGHT", MENU_NORMAL); delay(100); } else if (switchVoltage > 600 && switchVoltage < 800) { lcd.LCD_write_string(2, 2, "UP ", MENU_NORMAL); delay(100); } else if (switchVoltage > 800) { lcd.LCD_write_string(2, 2, "NONE ", MENU_NORMAL); delay(100); } }
[/codesyntax]
Link
AliExpress.com Product – LCD4884 LCD Joystick Shield v2.0 4884 LCD Expansion Board Raspberrypi