Post Reply 
Generic Calculator Shield for Arduino Photo-journal
03-14-2015, 10:01 PM (This post was last modified: 03-16-2015 06:57 AM by MarkHaysHarris777.)
Post: #26
RE: Generic Calculator Shield for Arduino Photo-journal
Greetings, the 16x2 back-lit display is operational using the LiquidCrystal library which provides support for displays compatible with the Hitachi HD44780 driver. I am using the Topway LMB162ABC LCD wired for four(4) bit and two control lines. As wired the Arduino 'hello,world!' example will run unmodified. This display is quite easy to put together from a hardware perspective, and very easy to write. Basically, you set the cursor, and write 'text' to one of the two output display lines. Hi-res pics first, code following:

[Image: pi-e-display2.jpg] [Image: arduino-display-wiring2.jpg]

Code:

/*
  Generic Calculator

 LCD Display:
 
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 15K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 */

// include the library code:
#include <LiquidCrystal.h>
#define BACKLIGHT 9

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  analogWrite(BACKLIGHT, 220);
  clearDisplay();
  say(0,0," Power-on Reset ");
  delay(1000);
  clearDisplay();
  say(0,0,"Calculator v0.01");
  say(0,1,"mh15cs");
  delay(1500);

}

void loop() {
  // print the number PI:
  say(0,0,"3.14159265358979");
  // print the number e:
  say(0,1,"2.71828182845904");
  delay(5000);
  // print the number PI:
  say(0,1,"3.14159265358979");
  // print the number e:
  say(0,0,"2.71828182845904");
  delay(5000);
}

void clearDisplay() {
  int i;
  for (i=0; i<=1; i++) {
      lcd.setCursor(0, i);
      lcd.print("                ");
   }
}

void say(int col, int lin, const char* outp) {
   lcd.setCursor(col, lin);
   lcd.print(outp);
}

-

The pot in the upper left is used to adjust the display contrast. The back light (yellow|green for the ABC model) is optional. I have provided a jumper which may be used to turn off the back light to save power. The display is of course easier to read with the back light, but is acceptable without it.

The display supports an 8 line data bus, of which I am using the high-order four(4) bits. {D4green(pin5), D5blue(pin4), D6violet(pin3), & D7grey(pin2)} RS(orange) is on pin 12, and Enable(yellow) is on pin 11. The red line is Vcc 5v (rail is on the end of the board), and the tan line is Vss ground, rail runs through the center.

This wiring diagram is the most common LCD wiring used with the 16x2 displays and the Arduino. Of course the same will work fine with any of the boards (Mega is shown) and also the Edison with the Arduino break-outs and Arduino IDE; I will be trying that shortly.


PS Since posting this update (while leaving the display on) the voltage regulator on the Mega got quite warm (hot even). So, the board is going to need its own 7805, if I run it with the back light lit up.

PPS I updated the code a bit...

Cheers,
marcus
Smile

Kind regards,
marcus
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Generic Calculator Shield for Arduino Photo-journal - MarkHaysHarris777 - 03-14-2015 10:01 PM



User(s) browsing this thread: 25 Guest(s)