Following my previous work to develop an Arduino code library for using an LCD display with the MCP23S17 port expander, I wrote a slightly modified version that works with the LCD mini click board from MikroElektronika.
This new library can be downloaded from:
https://github.com/Electronza/MIKROE_LCDmini.
While most of the library functions are described in the previous blog post, there are some changes that were necessary to match the hardware onboard the LCD mini click board.
In the new library, the LCD mini object is declared as:
MCP23S17_LCD(uint8_t rst, uint8_t cs, uint8_t cs2, uint8_t pwmpin);
Where:
- rst is the /reset pin of the MCP23S17 port expander
- cs is the /CS pin for MCP23S17
- cs2 is the /CS pin for MCP4161 digital potentiometer
- pwmpin is used to control backlight intensity
When using one Arduino Uno with the Arduino Uno click shield, the settings are as follows:
- MIKROE_LCDmini lcd(A3, 10, A0, 6); when using mikroBUS socket #1
- MIKROE_LCDmini lcd(A2, 9, A1, 5); when using mikroBUS socket #2
Obviously, don’t forget to move the (hardware) SMD jumper in the 5V position if you wish to use the LCD mini click board with 5V Arduino boards,
Besides this, the LCD is now initialized as lcd.begin();
. No parameters are necessary, as the LCD number of rows and columns is set inside the library.
As the LCD mini click uses a digital potentiometer to set the LCD contrast, a dedicated lcd.setContrast(uint8_t contrast);
function was implemented. In my example code I used contrast = 30, but you can play around this value until you get the desires result.
When started, the backlight is set to its maximum intensity. You can further control the backlight using the lcd.setBacklight(uint16_t backlight);
Possible values range from 0 to 1023.
A typical Arduino code will look like:
#include <MIKROE_LCDmini.h> MIKROE_LCDmini lcd(A3, 10, A0, 6); void setup() { lcd.begin(); lcd.setContrast(30); lcd.setBacklight(600); } void loop() { ... }
All other LCD functions are the same as described in the Arduino LCD library. All code examples were modified to reflect the changes in the library.
2 Comments
Do you have any plans to get this working on an Arduino Mega, with a 3 position click shield?
It should work fine on the Mega. Just remember to set the correct pins for RST, CS, CS2, and PWMPIN and to configure the LCD Mini click for 5V operation.
// MCP23S17_LCD(uint8_t rst, uint8_t cs, uint8_t cs2, uint8_t pwmpin);
For socket #1 you should have MIKROE_LCDmini lcd(49, 53, A0, 5);
For socket #2 you should have MIKROE_LCDmini lcd(48, 46, A1, 2);
For socket #3 you should have MIKROE_LCDmini lcd(47, 45, A2, 3);