📜 ⬆️ ⬇️

Arduino and LiquidCrystal

The LiquidCrystal library allows you to control LCD displays compatible with the Hitachi HD44780 driver. There are many, usually 16-pin, varieties.
This diagram displays “hello, habr!” On the LCD and shows the time in seconds after a reset.




')
We will need:


The contrast of the LCD depends on the amount of voltage that is fed to the control input. The higher the voltage, the lower the contrast and vice versa. The voltage should be about 0.5-1 V, but still depends on the ambient temperature. In our example, the PWM value is set to 50, which provides an output voltage level of about 1 V. Accordingly, you can increase or decrease this value to obtain the required level of contrast.

Using one of the PWM output with a capacitor, we will control the contrast from the program, where the value will be “hard”. Pin 9 of the Arduino, which is used as a PWM, is connected to the pin of the contrast control Vo LCD. A 100 microfarad capacitor connected between the PWM output and the common.

The pinout of the LCD Arduino is shown below:



And the actual code:

/*  : * LCD RS   .  12 * LCD Enable   .  11 * LCD R/W   * LCD VO  ( 3)  PWM- 9 * LCD D4   .  5 * LCD D5   .  4 * LCD D6   .  3 * LCD D7   .  2 */ #include <liquidcrystal.h> //   LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //       void setup() { pinMode(9, OUTPUT); analogWrite(9, 50); //  PWM  lcd.begin(16, 2); //  -    lcd.print("hello, habr!"); //    LCD } void loop() { //    0- , 1  (  0) lcd.setCursor(0, 1); lcd.print(millis()/1000); //      } </liquidcrystal.h> 


UPD: I got this whole game up. As there? “Moped is not mine ...” - this is not my article, I don’t need arduino nafig, but I threw an article on my own behalf of this img33.imageshack.us/img33/7060/selection001l.png person. He strongly wanted to Habr and wanted to write an article, and I would give him an invite for that. T.ch. I ask all the questions for him ... well, you want a minus, but do not mess me mail with comments.

Source: https://habr.com/ru/post/130355/


All Articles