I like fast things. And I like clean code. Often, the two go hand-in-hand 😉
After looking through the modified LiquidCrystal library for use with the i2c backpack and darn near crying when I saw all the faux digitalRead() and pinMode() being done on each transfer, I was bound and determined to never let that happen to another friendly Arduino user again. I first made a proof of concept modification to the library to “burst” all the “LiquidCrystal::send” bits instead of digitalWrite()’ing them out one at a time (read I2C, modify, write… read, modify, write… read, modify, write… read, modify, write – over 16 I2C commands for each single character). It worked great. I could do animation on the screen once again, and it was smooth.
OK, so the next step… package it up into something usable. I kept running into issues where Wire.h needed to be part of every program I use LiquidCrystal with. It just had to be “forked” to its own library. I’m sure C++ will allow a typedef alias for any libraries/sketches that have LiquidCrystal hard-coded into them… I just haven’t had a need yet. I fully gutted LiquidCrystal of all functions relating to digitalRead/digitalWrite, and made it 100% pure i2c. What a sleek beauty… just watch the video.
Of course, next on my to-do list is a proper animation library for character LCDs. 🙂
i2c / SPI character LCD backpack. LCD backpacks reduce the number of pins needed to connect to an LCD. LCDs are a fun and easy way to have your microcontroller project talk back to you. Character LCDs are common, and easy to get, available in tons of colors and sizes. (or similar microcontroller) but find that the number of pins necessary to control the LCD can be restrictive, especially with ambitious projects. We wanted to make a ‘backpack’ (add-on circuit) that would reduce the number of pins without a lot of expense.
By using simple i2c and SPI input/output expanders we have reduced the number of pins (only 2 pins are needed for i2c) while still making it easy to interface with the LCD. For Arduino users, we provide a easy-to-use library that is backwards compatible with projects using the ‘6 pin’ wiring.
This backpack will work with any ‘standard’ character LCD, from 8×1 to 40×4 sizes! As long as they have a 16-pin single-line connection header at the top. We carry a few LCDs that work great.
For advanced users, this project can be used for general purpose I/O expansion, the MCP23008 has 8 i/o pins (7 are connected) with optional pull-ups, the SPI 74HC595 has 7 connected outputs.
Adafruit publishes a wide range of writing and video content, including interviews and reporting on the maker market and the wider technology world. Our standards page is intended as a guide to best practices that Adafruit uses, as well as an outline of the ethical standards Adafruit aspires to. While Adafruit is not an independent journalistic institution, Adafruit strives to be a fair, informative, and positive voice within the community – check it out here: adafruit.com/editorialstandards
Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.
Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat and our Discord!