PIC 18 LCD First Print

Let’s make our first print — PIC Unit #02 — LCD — Episode #01

J3
Jungletronics
4 min readNov 25, 2019

--

Hi, in this previous initial series PIC episode, we’re talking about how to manipulate LCD’s bits and bytes via a cool simulator and a custom addresses spreadsheet.

Yes, the first step was really hard, and I dedicate myself to the goal of letting me (and you, eventually…) understand how LCD’s controller HD40780 works inside.

Knowing that was not easy to complete, but I think the effort did worth it. Those extra steps are so difficult and painful they almost never get done. So I did it for me and you and it is registered in the first episode of LCD unit 02.

Now it’s time to code!

Don’t despair, Libraries will shield us from hard work! This is awesome!
Now we feel a salty and fresh breeze hitting our faces…

Let’s get it on!

Each operation inside the chip is flagged by the Register Select pin, which connects to Microcontroller to shift between command/data register.

Now open your mikroc PRO for PIC app right away, go to the Help menu and at the index search for ‘LCD’. Choose Lcd Commands.

You will see a dummy initial code, to begin with. That’s easy enough, right?

Copy and paste its code to your new project.

Let’s addapt it to PIC18F4520(microgenios) or PIC18F45K22(easyPIC v7).

Here is mine:

Fig 1. LCD Hello World!
Fig 2. The final result for this code

Nothing special. The library did the hard work so you can pass your commands in a simple interface:

Lcd_Init();                         // Initialize LCD   Lcd_Cmd(_LCD_CLEAR);                // Clear display  Lcd_Cmd(_LCD_CURSOR_OFF);           // Cursor off

Now just call this method to print on the screen:

Lcd_Out(1,1,"First Line");          // Write text in first row  Lcd_Out(2,1,"Second Line");         // Write text in second row

Lcd_Out(Line, Column, Text).

See that the reward for work well done is the opportunity to do more. With the library in action, the selection of each Ascii character is automatic. All you need to do is pass a location and the string to the method Lcd_Out() and there you go!

All that work of selecting which mode to work with, what bits must be set on the data bus. etc, are left for the library.

This is why encapsulation is the key to success for a high-level programming language, like C.

And that is all for now!

On the next episode, let's implement our first animation on LCD using PIC18F, Alive and kicking!

Bye and tks a lot:)

Related Posts

0º Episode — LCD — unit#02 — PIC 18 LCD Intro — HD44780 Character LCD Displays

1º Episode — LCD — unit#02 — PIC LCD First Print — Let’s make our first print

2º Episode — LCD — unit#02 — PIC LCD First Animation — Let’s Unveil The LCD’s Animations Techniques

3º Episode — LCD — unit#02 — PIC LCD Key & Counter — Pressing One key Increment or Pressing Other Key Decrements a Counter

4º Episode — LCD — unit#02 — PIC LCD Custom Symbols — How to Create a Custom Character on CGRAM

5º Episode — LCD — unit#02 — PIC 18 Digital Thermometer — Designing a Digital Thermometer w/ LM35

6º Episode — LCD — unit#02 — PIC 18 LCD Calculator — Let’s Make an Awesome CalculatorApp

7º Episode — LCD — unit#02 — PIC 18 LCD Keypad Discovery — Let’s Unveil Our Board Keypad

8º Episode — LCD — unit#02 — PIC 18 LCD Menu Template — Get A Nice Template For Your Menu App

BTW:

What are the benefits of hard work?
Along with increased mental toughness, hard work gives you the chance to improve yourself. Hard work will help you develop self-discipline and focus. In turn, you will become more efficient and productive. You’re constantly improving your current skills and developing new ones.

Why Working hard is important?
Hard work is the only key to achieving it; it teaches us discipline, dedication, and determination. Hard work is definitely more important because it is only through hard work that we can achieve the goals of our life. Smart work, on the other hand, often leads to shortcuts and procrastination

High-level programming language
(From Wikipedia, the free encyclopedia)
In computer science, a high-level programming language is a programming language with strong abstraction from the details of the computer. In contrast to low-level programming languages, it may use natural language elements, be easier to use, or may automate (or even hide entirely) significant areas of computing systems (e.g. memory management), making the process of developing a program simpler and more understandable than when using a lower-level language. The amount of abstraction provided defines how “high-level” a programming language is.[1]

--

--

J3
Jungletronics

Hi, Guys o/ I am J3! I am just a hobby-dev, playing around with Python, Django, Ruby, Rails, Lego, Arduino, Raspy, PIC, AI… Welcome! Join us!