I bought the Artou version of this shield. My first move was to use an ohmmeter to buzz out the connections between the display unit and the IO pins to the Arduino board. Frabjous day! It matched the pins used by the DFRobot shield.
DFRobot LCD Shield has a wiki page with sample programs and documents. The buttons connect to analog input A0. Many IO pins from the Uno board are available as through-hole or headers.
ConnectionsWe find out that RS Register Select is connected to Arduino pin 8 and Enable is on pin 9. Display pins D4, D5, D6 and D7 are wired to matching board pins 4, 5, 6 and 7. RW Ready/Wait is not connected and not used in software.
Arduino comes, by default, with the LiquidCrystal library to use this display. We have an ATmega8 project using the same display and the same library but this time we need to change the default connection leads.
The examples in the library will work but we have to modify what is called a constructor.
Modify ConstructorIn OOP object oriented programming we are instantiating a data object of type LiquidCrystal named lcd. The return value of lcd(variables) depends upon the bits transmitted on the various wires. All examples in the LiquidCrystal library expect 4 data leads and two control leads.
Replace the two lines that tell software which leads to use with this updated line. The DFrobot Shield and copies are wired this way. Compile the sketch immediately to check. It is during these edits that mistakes are made.
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
By including the LiquidCrystal library we add defined functions to exchange data with the display module. Overloading is a C++ feature where defined functions are ready for 8bit or 4bit operation.
Open ExampleMenu File->Examples->LiquidCrystal->CustomCharacter locate the constructor line and update to correct wiring details. #include <LiquidCrystal.h> is an important command, it adds a library of code to control the display.
Upload to our Uno board and we should see a little animation. This updated sketch is attached to this project.
The ButtonsLook at the schematic and you see the reset that restarts the board and you see a ladder of resistances connecting to Analog Input 0. The voltage going to A0 depends upon which buttons are pressed.
Compile and upload the pacMan.ino sketch attached to this project. Goal is for PacMan to eat all the energy pills before the monster eats him. Move PacMan with your buttons and restart game with reset.
Go through all the examples in the LiquidCrystal library and change the constructor. Upload to board and watch results. Use the examples from DFRobot. Do Embedded Engineering project to compare C/C++, Arduino IDE and assembly language programming of this same display device.
Comments