Working with an LCD Screen: A Johnny Five Guide
tags: [“Johnny Five”, “LCD screen”, “Arduino”, “coding”, “electronics”]
LCD screens are versatile components that can be used in a variety of projects. In this guide, we will learn how to work with an LCD screen using the Johnny Five library. Let’s get started!
Getting Familiar with the LCD Screen
The LCD screen we will be using is the 1602A model, which has 16 pins. Here is how it should be wired:
1 | Pin 1: 0V |
Wiring the LCD Screen
To control the backlight, connect the middle pin of the potentiometer to the LCD screen, the left pin to 0V, and the right pin to 5V.
Initializing the LCD Object
Create a new file called lcd.js
and add the following code:
1 | const { Board, LCD } = require("johnny-five"); |
This code sets up the Johnny Five board and initializes a new LCD object from the LCD class. The pins
array specifies the Arduino pins connected to the LCD screen.
Displaying Text on the LCD Screen
To display a string on the LCD screen, add the following code:
1 | const { Board, LCD } = require("johnny-five"); |
Running the program with node lcd.js
will display the text on the LCD screen.
Additional Methods for LCD Screens
The LCD class provides convenient methods for controlling the screen. Here are some examples:
clear()
: Clears the screen.cursor()
: Positions the cursor at a specific place.off()
: Disables the display.on()
: Enables the display.blink()
: Blinks the cursor.noBlink()
: Stops blinking the cursor.autoscroll()
: Enables automatic scrolling when the message exceeds the screen size.
For more information on these methods, refer to the Johnny Five LCD documentation.
With this knowledge, you can start creating projects that incorporate LCD screens using Johnny Five and Arduino. Have fun exploring the possibilities!