MikroE Lcd Click Mini Library or Examples for this shield.

Good morning, I have been trying to test a Mikroe Mini LCD click board on a Arduino Uno.

I have an Arduino Uno and a Shield to allow me to use the Mikroe Click Boards. I also have a 4-20ma Click board which is the reason why I purchased the Uno Click Shield.

Hardware:-

Arduino Uno Arduino UNO click shield

LCD mini click displays 2x16 monochrome characters on an LMB162XFW LCD display. It features the MCP23S17 port expander and the MCP4161 digital potentiometer, both from Microchip.

LCD mini click is designed to run on either 3.3V or 5V power supply. It communicates with the target microcontroller over SPI interface and the following pins on the mikroBUS™ line: PWM, INT, RST, AN.

I also have a Click 4-20ma Shield which I have managed to test ok.

My Goal is to display the values being read onto the LCD, I currently have them Printing in the serial Monitor.

My problem is I cannot find a library for the LCD and I have found many different examples and methods using different libraries.

Some of the LCD libraries claim SPI support, then the other way is to use an MCP23s17 library.

I'm a bit overwhelmed with all the information.

Please could I have a push i the right drirection.

Thanks Andrew

Bump

First you try with a parallel LCD and learn how it’s respond, and there is an inbuilt LCDcrystal library available with example.

I gone through the Mikroe_LCDminiClick , there they use the parallel LCD display connected to MCP23S17 Port B and One Digiport (MCP4161)

  1. RST pin should be High (on click board)
  2. Digipot with correct value for LCD back light ( 0-127 )
  3. Send the data through SPI to MCP23s17 Port B

Flash the following code and check it. and modify based on your need.

#include <SPI.h>
#define CS 10
#define CS2 14
#define RST 17
#define digiPot 20
#define rs_pin 2
#define enable_pin 3
// commands
#define LCD_CLEARDISPLAY 0x01
#define LCD_RETURNHOME 0x02
#define LCD_ENTRYMODESET 0x04
#define LCD_DISPLAYCONTROL 0x08
#define LCD_CURSORSHIFT 0x10
#define LCD_FUNCTIONSET 0x20
#define LCD_SETCGRAMADDR 0x40
#define LCD_SETDDRAMADDR 0x80

// flags for display entry mode
#define LCD_ENTRYRIGHT 0x00
#define LCD_ENTRYLEFT 0x02
#define LCD_ENTRYSHIFTINCREMENT 0x01
#define LCD_ENTRYSHIFTDECREMENT 0x00

// flags for display on/off control
#define LCD_DISPLAYON 0x04
#define LCD_DISPLAYOFF 0x00
#define LCD_CURSORON 0x02
#define LCD_CURSOROFF 0x00
#define LCD_BLINKON 0x01
#define LCD_BLINKOFF 0x00

// flags for display/cursor shift
#define LCD_DISPLAYMOVE 0x08
#define LCD_CURSORMOVE 0x00
#define LCD_MOVERIGHT 0x04
#define LCD_MOVELEFT 0x00

// flags for function set
#define LCD_8BITMODE 0x10
#define LCD_4BITMODE 0x00
#define LCD_2LINE 0x08
#define LCD_1LINE 0x00
#define LCD_5x10DOTS 0x04
#define LCD_5x8DOTS 0x00
uint8_t _bitString;
uint8_t _displayfunction;
uint8_t _displaycontrol;
uint8_t _displaymode;
uint8_t _initialized;
uint8_t _numlines,_currline;
int onetime=0;

void string_write(char *data)
{
while(*data)
write(*data++);
}
void display() {
_displaycontrol |= LCD_DISPLAYON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void clear()
{
command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero
delayMicroseconds(2000); // this command takes a long time!
}
void begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
if (lines > 1) {
_displayfunction |= LCD_2LINE;
}
_numlines = lines;
_currline = 0;

// for some 1 line displays you can select a 10 pixel high font
if ((dotsize != 0) && (lines == 1)) {
_displayfunction |= LCD_5x10DOTS;
}

delayMicroseconds(50000);

digitalWrite(rs_pin, LOW);
digitalWrite(enable_pin, LOW);

write4bits(0x03);
delayMicroseconds(4500); // wait min 4.1ms

// second try
write4bits(0x03);
delayMicroseconds(4500); // wait min 4.1ms

// third go!
write4bits(0x03);
delayMicroseconds(150);

// finally, set to 4-bit interface
write4bits(0x02);

// finally, set # lines, font size, etc.
command(LCD_FUNCTIONSET | _displayfunction);

// turn the display on with no cursor or blinking default
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
display();

// clear it off
clear();

_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
// set the entry mode
command(LCD_ENTRYMODESET | _displaymode);

}

inline void command(uint8_t value) {
send(value, LOW);
}

inline size_t write(uint8_t value) {
send(value, HIGH);
return 1; // assume sucess
}

// write either command or data, with automatic 4/8-bit selection
void send(uint8_t value, uint8_t mode) {

bitWrite(_bitString, rs_pin, mode); //set RS to mode
spiSendOut();
write4bits(value>>4);
write4bits(value);

}

void pulseEnable(void) {
bitWrite(_bitString, enable_pin, LOW);
spiSendOut();
delayMicroseconds(1);
bitWrite(_bitString, enable_pin, HIGH);
spiSendOut();
delayMicroseconds(1); // enable pulse must be >450ns
bitWrite(_bitString, enable_pin, LOW);
spiSendOut();
delayMicroseconds(40); // commands need > 37us to settle
}
void spiSendOut() //SPI #############################
{

digitalWrite(CS, LOW);
SPI.transfer(0x40);
SPI.transfer(0x13);
SPI.transfer(_bitString);
digitalWrite(CS, HIGH);
}
void write4bits(uint8_t value) {
for (int i = 4; i < 8; i++)
{
//we put the four bits in the _bit_string
bitWrite(_bitString, i, ((value >> (i - 4)) & 0x01));
}
//and send it out
spiSendOut();
pulseEnable();
}

void setup() {
pinMode (CS, OUTPUT);
SPI.begin();

pinMode (RST, OUTPUT);
pinMode (CS2, OUTPUT);
digitalWrite(RST, HIGH);
digitalWrite(CS2, HIGH);

digitalWrite(CS, LOW);
SPI.transfer(0x40); // 0x40
SPI.transfer(0x0A);
SPI.transfer(0x20);
digitalWrite(CS, HIGH);

digitalWrite(CS, LOW);
SPI.transfer(0x40); // 0x40
SPI.transfer(0x01);
SPI.transfer(0x00);
digitalWrite(CS, HIGH);

digitalWrite(CS2, LOW);
SPI.transfer(0x00);
SPI.transfer(digiPot);
digitalWrite(CS2, HIGH);

//_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
begin(16,2,0);
}

void loop() {
if(onetime==0)
{
onetime++;

clear();
//write(‘H’);
//write(‘D’);
string_write(“LCD Click:”);
}
}

A library for LCD mini click: https://github.com/Electronza/MIKROE_LCDmini