Connect I2C LCD 16×2 Display to Arduino Nano

In this Instructable you are going to see how to connect i2c lcd display to arduino and how to print on lcd display.

Each I2C bus consists of two signals: SCL and SDA. SCL is the clock signal, and SDA is the data signal. The clock signal is always generated by the current bus master; some slave devices may force the clock low at times to delay the master sending more data (or to require more time to prepare data before the master attempts to clock it out). This is called “clock stretching” and is described on the protocol page.

To connect 16×2 LCD display to Arduino we use i2c PCF 8574T module. This module expands Arduino pins and allow connection of display using only two Arduino pins.

I2C module has four pins: GND – ground, VCC – 5V power, SDA – data signal, SCL – clock signal. Connect SDA to A4 pin on Arduino, and SCL to A5 pin:

GND <---> GND
VCC <---> 5V
SDA <---> A4
SCL <---> A5

For working with display on Arduino we need two libraries: Wire.h, LiquidCrystal_I2C.h.

Wire.h is standard Arduino IDE library, and LiquidCrystal_I2C.h is the library for work with LCD displays. You can download it from official Arduino project website: https://www.arduino.cc/reference/en/libraries/liquidcrystal-i2c/

And here is the source code of simple sketch, which write text on 16×2 LCD display:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);

void setup() 
{
  lcd.init();
  lcd.backlight();

  lcd.setCursor(0,0); // set cursor to 1 symbol of 1 line
  lcd.print("Arduino Lessons:");

  lcd.setCursor(0,1); // set cursor to 1 symbol of 2 line
  lcd.print("www.andjey.info"); 
}

void loop() 
{  

}

Arduino – simple blink program

Let’s write simple program, that will turn on and off LED on our Arduino. For our lesson we need: Arduino, one LED diode, USB cable for programming our Arduino, PC with Arduino IDE, download it you can here: https://www.arduino.cc/en/software

Connect USB cable to Arduino, for connecting LED we will use D13 pin and GND PIN (see Arduino Nano pins here). Positive wire of diode connect to D13, negative wire – to Ground pin as you can see on photo:

In Arduino IDE create new blank project:

Here You can see two functions: setup() – which run when Arduion power on, and function loop() – which run in cycle all type when arduino is working. Now let’s create our program.

Bewore function start() let’s create two constants – it will be basic configuration of our program. BLINK_PIN defines which pin is used for connecting LED. BLINK_TIME – define time in milliseconds how long our LED will be on and off.

#define BLINK_PIN 13
#define BLINK_TIME 1000

In function setup() configure pin 13 as output pin:

void setup() {
  pinMode(BLINK_PIN,1);
}

Now create function blink_led() – that will turn on and off our LED:

void blink_led()
{
  digitalWrite(BLINK_PIN, 1);
  delay(BLINK_TIME);
  
  digitalWrite(BLINK_PIN, 0);
  delay(BLINK_TIME);
}

Now write function blink_led() in loop() to run our program in cycle all time when Arduino works:

void loop() {
  blink_led();
}

Full code of program:

#define BLINK_PIN 13
#define BLINK_TIME 300

void blink_led()
{
  digitalWrite(BLINK_PIN, 1);
  delay(BLINK_TIME);
  
  digitalWrite(BLINK_PIN, 0);
  delay(BLINK_TIME);
}

void setup() {
  pinMode(BLINK_PIN,1);
}

void loop() {
  blink_led();
}

Now save program and compile it to your Arduino:

Visual Studio Code first config

Visual Studio Code is a very powerful free and open source text editor, but before start usage it you need to but to use all its features, you need to configure it.

Visual Studio Code

First of all disable telemetry collection in File > Preferences > Settings menu:

Override “Alt” button to toggle menu bar:

"window.titleBarStyle": "custom",
"window.customMenuBarAltFocus": false

Disable file previewing when clicked on at all is by setting:

"workbench.editor.enablePreview": false

Functionality of Visual Studio Code can be extended with plugins and extensions.

To disable Unicode strings highlight use command:

editor.unicodeHighlight.ambiguousCharacters = false

To change tabulation for existing document use command:

indent using tabs

I prefer to install such basic plugins: Project Manager, Ftp-sync, Show Functions, Beautify, and Material Icon Theme, Atom Material Theme:

This is my basic configuration of Visual Studio Code, you can also change other options and config this amazing text editor as you want.

How to change MySQL root password in Debian / Ubuntu

Connect to MySQL Server using Linux terminal:

sudo mysql --user=root mysql

Run the following commands:

UPDATE mysql.user SET authentication_string=null WHERE User='root';
flush privileges;

Replace NEW_PASSWORD with your own.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NEW_PASSWORD';
flush privileges;
exit;

How to Flush the DNS Cache on Debian 10

To flush DNS cache in Debian GNU/Linux use command:

sudo systemd-resolve --flush-caches

If you get error message: “Failed to flush caches: Unit dbus-org.freedesktop.resolve1.service not found.“, enable the service on your system:

sudo systemctl enable systemd-resolved.service

Then again run the “systemd-resolve –flush-caches” command.

You can then check the statistics in order to make sure that your cache size is now zero, thus cleared. Run the following command in order to view the statistics:

sudo systemd-resolve --statistics

Configure certificate in HestiaCP

1. Backup current certificates in directory /usr/local/hestia/ssl/:

mv /usr/local/hestia/ssl/certificate.crt /usr/local/hestia/ssl/certificate.crt.old 

mv /usr/local/hestia/ssl/certificate.key /usr/local/hestia/ssl/certificate.key.old 

2. In directory /usr/local/vesta/ssl/ make symbol links to certificates, that we use on our site (for example: site.com):

ln -s /home/admin/conf/web/site.com/ssl/site.com.crt /usr/local/hestia/ssl/certificate.crt 

ln -s /home/admin/conf/web/site.com/ssl/site.com.key /usr/local/hestia/ssl/certificate.key 

3. Restart Hestia service:

service hestia restart

Bitcoin price exceeded $ 49,000

On Tuesday, February 16, the price of bitcoin rises. At 09:25, the first cryptocurrency is trading at $ 49,594.3 (+ 3.70%), according to CoinMarketCap.

Bitcoin adds 4% per day and trades about $49,500. The most popular cryptocurrency is once again attempting to storm the most important psychological and technical level of $50,000.

Confident overcoming of this mark will increase the buying momentum not only for Bitcoin, but for the entire cryptocurrency market. Along with BTC, all altcoins returned to growth.

The total capitalization of the cryptocurrency market jumped to $1.5 trillion. It seems that Elon Musk’s statement on the purchase of bitcoins for $1.5 billion was a kind of analogue of the statement of the head of the Federal Reserve about his readiness to continue stimulating the economy.

Together, these two events seem to have postponed the moment when a broad market correction began. Technical indicators indicate an overheated state of the market, but so far this does not interfere with growth. The RSI for the BTC/USD pair on the daily chart shows a transition to the overbought zone, but so far this trend is moderate.

Elon Musk continues to make loud statements, and this time he again paid attention to Dogecoin, inviting whales to buy back their coins in exchange for his support for the project. It is difficult to say exactly what goals Musk is pursuing in the context of Dogecoin, but such news feeds definitely cause positive vibrations in the crypto market.

Best JavaScript libraries

Lodash (https://lodash.com/)

Lodash makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc. Lodash’s modular methods are great for:

  • Iterating arrays, objects, & strings
  • Manipulating & testing values
  • Creating composite functions

Quill Text Editor (https://quilljs.com/)

Quill is a free, open source WYSIWYG editor built for the modern web. With its modular architecture and expressive API, it is completely customizable to fit any need.


Leaflet (https://leafletjs.com/)

Leaflet is the leading open-source JavaScript library for mobile-friendly interactive maps. Weighing just about 39 KB of JS, it has all the mapping features most developers ever need.

Leaflet is designed with simplicity, performance and usability in mind. It works efficiently across all major desktop and mobile platforms, can be extended with lots of plugins, has a beautiful, easy to use and well-documented API and a simple, readable source code that is a joy to contribute to.


How to exit vim? And other required commands.

Vim is the most popular Linux text editor, it was created in 1978 and is used to present days.

Vim has two modes: “Command mode” where you can insert many commands, and “Insert mode” – where you can insert and edit text document. By default Vim open all documents in “Command mode”, to enter into the “Insert mode” – press button “i“.

The most asked question is – “How to exit Vim?” – it is very simple – in Command mode enter :q! and press Enter. This command exit Vim without saving any changes.

:q!

To save file – enter command :w <filename> and press Enter:

:w file.txt

To save file and exit Vim use command :wq and press Enter

:wq