Johnny Five, how to work with an LCD Screen

This post is part of the Johnny Five series. See the first post here.

An LCD screen is a pretty cool component because we can use it for many different projects in creative ways.

This one I have is named 1602A.

It has 16 pins. I wired…


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com

This post is part of the Johnny Five series. See the first post here.

An LCD screen is a pretty cool component because we can use it for many different projects in creative ways.

This one I have is named 1602A.

It has 16 pins. I wired it in this way:

  • Pin 1 goes to 0V
  • Pin 2 goes to a potentiometer that controls the backlight
  • Pin 3 is connected to 5V
  • Pin 4 goes to Pin 7 on the Arduino
  • Pin 5 goes to 0V
  • Pin 6 goes to Pin 8 on the Arduino
  • Pin 11 goes to Pin 9 on the Arduino
  • Pin 12 goes to Pin 10 on the Arduino
  • Pin 13 goes to Pin 11 on the Arduino
  • Pin 14 goes to Pin 12 on the Arduino
  • Pin 15 goes to 5V
  • Pin 16 goes to 0V

The potentiometer has 3 pins. The middle one is connected to the LCD screen, the left one is 0V and the right one 5V:

That’s it for the wiring.

Create a new lcd.js file and load this code:

const { Board, LCD } = require("johnny-five")
const board = new Board()

board.on("ready", function () {})

Now initialize a new LCD object from the LCD class.

The exact initialization procedure depends on the kind of display used. In my case, it was this:

const lcd = new LCD({ pins: [7, 8, 9, 10, 11, 12] })

Finally, call the print() method to display a string:

const { Board, LCD } = require("johnny-five")
const board = new Board()

board.on("ready", function () {
  const lcd = new LCD({ pins: [7, 8, 9, 10, 11, 12] })
  lcd.print("Hello World!")
})

and run the program using node lcd.js to see it work:

The LCD class also offers those cool methods:

  • clear() to clear the screen
  • cursor() to position the cursor at a specific place
  • off() to disable the display
  • on() to enable the display
  • blink() to blink the cursor
  • noBlink() to un-blink the cursor
  • autoscroll() to turn on automatic scrolling when the message goes too long

You can find out more on http://johnny-five.io/api/lcd/.


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com


Print Share Comment Cite Upload Translate Updates
APA

flaviocopes.com | Sciencx (2021-04-28T05:00:00+00:00) Johnny Five, how to work with an LCD Screen. Retrieved from https://www.scien.cx/2021/04/28/johnny-five-how-to-work-with-an-lcd-screen/

MLA
" » Johnny Five, how to work with an LCD Screen." flaviocopes.com | Sciencx - Wednesday April 28, 2021, https://www.scien.cx/2021/04/28/johnny-five-how-to-work-with-an-lcd-screen/
HARVARD
flaviocopes.com | Sciencx Wednesday April 28, 2021 » Johnny Five, how to work with an LCD Screen., viewed ,<https://www.scien.cx/2021/04/28/johnny-five-how-to-work-with-an-lcd-screen/>
VANCOUVER
flaviocopes.com | Sciencx - » Johnny Five, how to work with an LCD Screen. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/28/johnny-five-how-to-work-with-an-lcd-screen/
CHICAGO
" » Johnny Five, how to work with an LCD Screen." flaviocopes.com | Sciencx - Accessed . https://www.scien.cx/2021/04/28/johnny-five-how-to-work-with-an-lcd-screen/
IEEE
" » Johnny Five, how to work with an LCD Screen." flaviocopes.com | Sciencx [Online]. Available: https://www.scien.cx/2021/04/28/johnny-five-how-to-work-with-an-lcd-screen/. [Accessed: ]
rf:citation
» Johnny Five, how to work with an LCD Screen | flaviocopes.com | Sciencx | https://www.scien.cx/2021/04/28/johnny-five-how-to-work-with-an-lcd-screen/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.