OOSMOS LCD Example
1. Introduction
2. LCD on Various Platforms

1. Introduction

This example demonstrates how to write data to a two- or four-row HD44870 LCD device on multiple platforms.

2. LCD on Various Platforms

Because each platform could have unique pins or header layouts, we show LCD on multiple platforms in the following sections.

2.1 LCD on Arduino

The Arduino is a breeze to wire up. The pin assignments are printed on the Arduino circuit board and those are the numbers used to address them in the code.
Figure 1. Arduino Wiring Diagram
This is the main program for LCD on the Arduino.
1
22
23
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
[GPLv2]
 
#includes...
 
extern void setup()
{
pin * pRS = pinNew(2, pinOut, pinActiveHigh);
pin * pE = pinNew(3, pinOut, pinActiveHigh);
pin * pData4 = pinNew(4, pinOut, pinActiveHigh);
pin * pData5 = pinNew(5, pinOut, pinActiveHigh);
pin * pData6 = pinNew(6, pinOut, pinActiveHigh);
pin * pData7 = pinNew(7, pinOut, pinActiveHigh);
 
lcdtestNew(pRS, pE, pData4, pData5, pData6, pData7);
}
 
extern void loop()
{
oosmos_RunStateMachines();
}
LcdExample.ino - LCD for Arduino

2.2 LCD on PIC32

Wiring diagram for LCD.
Figure 2. PIC32 Wiring Diagram
This is the main LCD program for the PIC32.
1
22
23
26
27
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
[GPLv2]
 
#includes...
 
#pragmas...
 
extern int main(void)
{
oosmos_ClockSpeedInMHz(80);
 
//
// Setup and drive an HD44870 LCD device.
//
pin * pRS = pinNew(IOPORT_E, BIT_0, pinOut, pinActiveHigh);
pin * pE = pinNew(IOPORT_E, BIT_1, pinOut, pinActiveHigh);
pin * pData4 = pinNew(IOPORT_E, BIT_2, pinOut, pinActiveHigh);
pin * pData5 = pinNew(IOPORT_E, BIT_3, pinOut, pinActiveHigh);
pin * pData6 = pinNew(IOPORT_E, BIT_4, pinOut, pinActiveHigh);
pin * pData7 = pinNew(IOPORT_E, BIT_5, pinOut, pinActiveHigh);
 
lcdtestNew(pRS, pE, pData4, pData5, pData6, pData7);
 
for (;;) {
oosmos_RunStateMachines();
}
}
Main program for LCD on PIC32
Copyright © 2014-2024  OOSMOS, LLC