Talking to LCD with only ATMEGA chip

Hi everyone,

I have read the stickies but they weren’t much help…

I have here a Powertip LCD module (PC1602-H) and an Arduino Uno rev 3. The plan is to create an ultrasonic rangefinder, and display the distance on the LCD. Problem is I have never coded before, although my electronics knowledge is solid.

The guides I found online tell me I should use the “int” command to define which pins to send data to on the LCD - but the pins it refers to are not the pins on the ATMEGA328, but the pins on the “DIGITAL” i/o ports.

For instance, an online guide tells me to define pin 10 as an output, but pin 10 on the ATMEGA is one of the XTAL pins, and not a useable output.

Please find the schematic attached.

The “LCD” header are the 8 available pins to use for the LCD display.

Thanks

When you are programming, Pin 10 refers to the Logical Pin 10 (or D10, meaning it is a Digital pin), not the physical (as "in the chip") pin 10.

Pin 10, in the Arduino code, refers to the physical pin 23 on the Atmega2560 chip.

Here is the pin mapping for the AtMega2560:

Thanks AlxDroidDev,

It seems that the LCD i bought was dead on arrival, I have now procured another and it is working perfectly! Also i was using the atmega328, not the 2560, but the pighixxx website has all the pinouts, thanks for the link :slight_smile:

I got the screen to work by including the following #define lines.

#include <LiquidCrystal.h>
#define LCD_RS 8                    // Register select
#define LCD_EN 9                    // Enable
#define LCD_D4 10                   // Data bits
#define LCD_D5 11                   // Data bits
#define LCD_D6 12                   // Data bits
#define LCD_D7 13                   // Data bits

The LCD has 16 pins, but I didnt use some of them

here was the pinout for anyone that sees this and needs it:

1- gnd
2-+5v
3- contrast (connect to ground though a 820ohm resistor)
4- Reg select (connect to 5v)
5- data read/write (connect to gnd)
6- enable (connect to 5v)
7- data0 (unused)
8- data1 (unused)
9- data2 (unused)
10- data3 (unused)
11- data 4 (connected to digital output)
12- data 5 (connected to digital output)
13- data 6 (connected to digital output)
14- data 7 (connected to digital output)
15- +ve for backlight (i didnt use)
16- -ve for backlight (i didnt use)