Вы находитесь на странице: 1из 15

Arduino : Using Displays...

1.1 Introduction

Liquid crystal displays (LCDs) offer a convenient and inexpensive way to provide a user interface for a project. This chapter explains how to connect and use common text and graphical LCD panels with Arduino. LCDs can do more than display simple text: words can be scrolled or highlighted and you can display a selection of special symbols and non-English characters.

1.1 Introduction

LCD displays have many wires connecting to Arduino Incorrect connections are the major cause of problems with LCDs, so take your time wiring things up and triple-check that things are connected correctly. The most popular LCD is the text panel based on the Hitachi HD44780 chip( LCD 2x16 )

1.2 Connecting a text LCD display

What will we need ?

Arduino IDE(Integrated Development Environment) for Linux, Windows or MacOS An Arduino Uno(or any other ardu-compatible) Some wires for the connections An LCD display(as said before) A 10k Potentiometer A breadboard to make the Y connections LCD Schematic Circuit And...

Imagination...!

Be careful!
Double-check the wiring before you apply power, as you can damage the LCD if you connect the power pins incorrectly. Also it is useful to know that there are many different lcd schematics every one depending on the model of LCD used. For LCD used in this tutorial we have the following schematic...

1.3

LCD Schematic
(for my LCD)

1.3 Hello World

Connect Arduino with you pc through USB port and don't remove it until the procedure will be finished. After wiring the schematic run Arduino IDE To run the HelloWorld sketch provided with Arduino, click the IDE Files menu item and navigate to ExamplesLibraryLiquidCrystalHelloWorld and you'll have the following output...

1.3 Hello World


// include the library code: #include <LiquidCrystal.h> // 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); // Print a message to the LCD. lcd.print("hello, world!"); } void loop() { // set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print(millis()/1000); }

1.3 Hello World

Now click Verify on the up left corner of the Arduino IDE window... It will take some seconds till the code will be mounted to the Arduino... You should see hello world displayed on the first line of your LCD. The second line will display a number that increases by one every second. And the circuit will be like this...

1.4 Comments

If you dont see any text and you have double-checked that all wires are connected correctly, you may need to adjust the contrast pot. With the pot shaft rotated to one side (usually the side connected to Gnd), you will have maximum contrast and should see blocks appear in all the character positions. With the pot rotated to the other extreme, you probably wont see anything at all. The correct setting will depend on many factors, including viewing angle and temperatureturn the pot until you get the best-looking display.

1.4 Comments

If you cant see blocks of pixels appear at any setting of the pot, check that the LCD is being driven on the correct pins. Once you can see text on the screen, using the LCD in a sketch is easy. You use similar print commands to those for serial printing.

See Also

Arduino IDE : http://arduino.cc/en/Main/Software LiquidCrystal reference: http://arduino.cc/en/Reference/LiquidCrystalPrint The LCD page in the Arduino Playground contains software and hardware tips and links: http://arduino.cc/playground/Code/LCD

Bibliography

Arduino Cookbook, O'REILLY

General Info sources

Arduino.cc(It's enough!) Arduino Cookbook

Made for Hellenic Air Force Academy...

Вам также может понравиться