Advice 1: How to connect a LCD display with I2C module for Arduino

In the article we will connect to Arduino LCD 1602 I2C module FC-113, whereby the connection will be performed only two data wires and two power wires.
LCD display I2C adapter
You will need
  • - Arduino;
  • - 1602 LCD display (16 characters, 2 lines);
  • - I2C adapter FC-113;
  • - connecting wires.
Instruction
1
Module FC-113 is based on the PCF8574T chip, which is an 8-bit shift register - "extender" of the inputs / outputs for the I2C. Figure IC is designated DD1.
R1 is the trimming resistor for adjusting contrast of the LCD display.
Jumper J1 is used to enable the backlight.
Insights 1...16 are used to connect the module to the conclusions of the LCD display.
Pads A1...A3 need to change the I2C address of the device. Sapaeva jumpers, you can change the address of the device. The following table lists the address mapping and jumper: "0" corresponds to the open circuit, "1" - installed jumper. By default, the device address 0x27, i.e. all 3 jumpers are open.
Device IIC module FC-113
2
The module is connected to the Arduino is the standard for I2C bus: SDA output module connects to the analog port A4, SCL to analog port Arduino A5. The module is powered by the voltage of +5V from the Arduino. The module itself is connected between pins 1...16 with the respective pins 1...16 on the LCD display.
Wiring diagram for the I2C module FC-113 to the LCD display and Arduino
3
Now need a library to work with the LCD via I2C. It is possible to use, for example, like this: http://www.dfrobot.com/wiki/index.php?title=I2C/TWI_LCD1602_Module_(SKU:_DFR0063)#Sample_Code (link in the line "Download Sample code and library").
Downloaded archive "LiquidCrystal_I2Cv1-1.rar" rotaryforum in the folder "\libraries\", which is located in the directory of Arduino IDE.
The library supports a set of standard functions for LCD screens:
LiquidCrystal() - creates a variable of type LiquidCrystal and accepts the connection settings of the display (pin numbers),
begin() - initializes the LCD display, the setting of parameters (number of lines and characters);
clear() - clear screen and return cursor to start position;
home() - return the cursor to the initial position;
setCursor() - set the cursor to a predetermined position;
write() - displays the character on LCD screen;
print() - displays text on the LCD screen;
cursor() - shows the cursor, i.e. the underline under the next character;
noCursor() - hides the cursor.
blink() - blinking cursor.
noBlink() - cancels the flashing;
noDisplay() - turns off the display keeping all the display information;
display() - enable the display while maintaining all of the displayed information;
scrollDisplayLeft() - scrolls through display 1 position left.
scrollDisplayRight () to scroll contents of the display 1 position to the right;
autoscroll() - turns on Autoscroll;
noAutoscroll() - turns off auto scroll;
leftToRight() - sets the text direction from left to right;
rightToLeft() - text direction from right to left.
createChar() - creates a custom character for the LCD screen.
Installing the library LiquidCrystal_I2C
4
Open the example: File -> examples -> LiquidCrystal_I2C -> CustomChars and slightly Refine it. Print the message at the end of which will be a flashing symbol. In the code comments, commented out all the nuances of the sketch.
Sketch with a random character
5
A little more, consider creating your own characters for LCD screens. Each character consists of 35 dots: 5 in width and 7 in height (+1 backup line to underline). In line 6 the above sketch, we set an array of 7 integers: {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0}. Convert a 16-hexadecimal numbers in binary: {00000, 01010, 11111, 11111, 01110, 00100, 00000}. These numbers - not that other, as a bit mask for each of the 7 strings, where "0" denote the light point, and 1 is dark. For example, the heart symbol that is specified in the form of a bit mask will appear on the screen as shown in the figure.
Create your own characters by using bitmask
6
Upload the sketch in Arduino. Will appear on the screen for controlling the inscription with a blinking cursor at the end.
LCD screen connected to Arduino via the serial I2C interface

Advice 2: I2C interface and Arduino

In this article we will look at what I2C interface (AI-Tu-si, and two TSE), what are its characteristics and how to work with it.
I2c interface
You will need
  • - Arduino;
  • digital potentiometer AD5171;
  • led;
  • - resistor 220 Ohm,
  • - 2 resistor 4.7 kOhm;
  • - connecting wires.
Instruction
1
Serial communication Protocol IIC (also called I2C - Inter-Integrated Circuits, minicasino connection) used to transfer data for two bidirectional communication lines, which are called the serial data SDA (Serial Data) and the bus clock SCL (Serial Clock). There are also two lines for food. Bus SDA and SCL are pulled to the power bus through the resistors.
The network has at least one master device (Master) which initialisere data transfer and generates the synchronization signals. The network also has a slave device (Slave) that transmit data upon request of the presenter. Each slave has a unique address, which is a leading and turns to him. The device address specified in the passport (datasheet). To the same I2C bus can connect up to 127 devices, including several leading. The bus devices can be connected in the process, i.e. it supports "hot plugging".
Connection diagram for I2C interface
2
The Arduino uses the I2C interface two ports. For example, the Arduino UNO and Arduino Nano analog port A4 corresponds to SDA, analog port A5 corresponds to SCL.
For other models:
Arduino Pro and Pro Mini to A4 (SDA), A5 (SCL)
The Arduino Mega is 20 (SDA), 21 (SCL)
Arduino Leonardo - 2 (SDA), 3 (SCL)
Arduino Due - 20 (SDA), 21 (SCL), SDA1, SCL1
Compliance findings tyres Arduino SDA and SCL
3
To facilitate data exchange with devices on the I2C bus for Arduino is written standard library "Wire". It has the following functions:
begin(address) - initialize the library and connect to the I2C bus; if the address is not specified, the attached device is considered a leading; use 7-bit addressing;
requestFrom() - used by the master to request a certain number of bytes from the slave;
beginTransmission(address) - start data transfer to the slave at a particular address;
endTransmission() - end of the slave transmission;
write() - write data from the slave in response to the request;
available() - returns the number of bytes of information available for the reception from a slave;
read() - read bytes transferred from the host or the slave from the master to the slave;
onReceive() - specifies a function that should be called when the slave receives a transmission from the master;
onRequest() - specifies a function that should be called when the host device receives the transmission from the slave.
4
Let's see how to work with the I2C bus with Arduino.
First assemble the circuit as shown. Will control the brightness of the led using digital 64-position potentiometer AD5171, which is connected to the I2C bus. The address to which we will refer to the potentiometer - 0x2c (44 decimal).
Control scheme for the led using a digital potentiometer and an Arduino
5
Now open the examples library "Wire" sketch:
File -> examples -> Wire -> digital_potentiometer. Upload it into the Arduino memory. Turn on.
You see, the brightness of the led cycles increases, and then abruptly turns off. In this case we control the potentiometer with the Arduino using the I2C bus.
Sketch control a digital potentiometer via I2C bus

Advice 3: How to connect a LCD display for Nokia 5110 for Arduino

Deal with connecting a LCD monochrome display with a resolution of 84х48 points from the Nokia 5110 to the Arduino.
LCD screen for Nokia 5110
You will need
  • - Arduino;
  • LCD display for Nokia 5110/3310;
  • - connecting wires.
Instruction
1
Connect LCD from Nokia 5110 Arduino according to the diagram above.
Connection diagram of LCD screen Nokia 5110 for Arduino
2
To work with this LCD screen written a lot of libraries. I suggest to use this: http://www.rinkydinkelectronics.com/library.php?id=44 (the downloading of the file LCD5110_Basic.zip).
To install rotaryforum the file to the directory of Arduino IDE/libraries/.
The library supports the following features.
LCD5110(SCK, MOSI, DC, RST, CS); - the announcement LCD screen showing the matching Arduino pins;
InitLCD([contrast]); - initialization of the 5110 display with optional indication of the contrast (0 to 127), the default value is 70;
setContrast(contrast); sets the contrast (0 to 127);
enableSleep(); - puts the screen to sleep mode;
disableSleep(); - displays a screen from sleep mode;
clrScr(); - clears the screen;
clrRow(row, [start], [end]); - clear the selected line number of the row, from position start to end;
invert(true); invert(false); - disabling and enabling the inversion of the contents of the LCD screen;
print(string, x, y); - displays the character string with the specified coordinates; the x-coordinates you can use LEFT, CENTER and RIGHT; the height of the standard font is 8 points, so the line should go, with intervals of 8;
printNumI(num, x, y, [length], [filler]); - print the number on the screen at the given position (x, y); length - the desired length of the number; filler - the character to fill the "voids" if the number is less than the desired length; the default is an empty space " ";
printNumF(num, dec, x, y, [divider], [length], [filler]); - display a floating-point number; dec - number of decimal places divider - sign decimal separator, by default a period ".";
setFont(name); - choose the font; the built-in font called SmallFont and TinyFont; you can define your fonts in the sketch;
invertText(true); invertText(false); - invert text on/off.off;
drawBitmap(x, y, data, sx, sy); - bring a picture to the screen coordinates x and y; data - an array containing the image; sx and sy are the width and height of the picture.
3
Write this sketch. First, attach the library, then declare an instance of the class LCD5110 with the terminal assignment.
In the procedure setup() initialize the LCD screen.
In the procedure loop() clear the screen and write in the small print arbitrary text underneath - medium font, display seconds counter.
The sketch to display text on the LCD screen Nokia 5110
4
Let's display picture. To do this, prepare a monochrome image that you want to display Nokia 5110. Remember that the screen resolution is 48 by 84 points, and the picture should be no more. On the page http://www.rinkydinkelectronics.com/t_imageconverter_mono.php convert image to array of bits. Download the resulting file with the extension "*.c" and add it to the project via the menu: Sketch -> Add file... or just put the file in the sketch directory, and then restart the Arduino development environment IDE.
Add the image file to the Arduino project
5
Now we need the code to declare an array with the image data (in my code this line extern uint8_t mysymb[];) and then use the function drawBitmap() to display the image in the desired location on the screen.
Output to LCD Nokia 5110
6
Upload the sketch in Arduino. Now the text is replaced by the picture, and every time the counter increases its value.
Text and image on the LCD screen Nokia 5110
Is the advice useful?
Search