Introduction: Replicating "Old-School" Texting With an Arduino, a 4x4 Numerical Keypad, and a 16x2 LCD
Hello! This is a tutorial to produce a text-composition device using an Arduino with text storage and return capabilities to the serial console. In its current form it is not particularly useful, and is more of an entertaining exercise, but the hardware setup and code may be expanded upon or incorporated into other projects as a relatively cheap way to compose text. With the addition of a GSM or 3G shield, and minor code changes and additions, this setup could actually be used as a simple text-sending phone.
Here is a video demo of most of the functionality, including text entry, line wrapping, screen-clearing, spaces, backspaces, serial output, and the end of composition menu, featuring the re-display of stored text upon backspacing, as well as the capability to output a final message and clear the display and storage.
You will need:
An Arduino (I used an Uno R3)
A 16x2 LCD (with or without backlight, your choice. Different sizes could be used with accommodations made in the code)
A breadboard, male-male and male-female jumpers (depends on how permanent this will be, and what headers are where)
5x 2k ohm resistors
1x 240 ohm resistor
The resistor values are not nessisarily set in stone, the 2k ones could most likely be subbed with anything 1k-5k, and the 240 could be anything 100-500, but I make no guarantees that those will cooperate (they probably will though). One of the 2k's and the 240 are used for creating a voltage divider for the contrast on the LCD. Normally this is accomplished with a potentiometer, so substitute as you feel fit.
Step 1: Hardware Setup
The diagram should explain the majority of the hardware setup, which is essentially an expansion of your typical basic LCD setup. Data output lines, however, are shared between the LCD and the keypad. These outputs go to the rows on the keypad in order to normally write them high. If any press occurs, it is detected by one of the columns going high, as the columns are hooked up to be inputs. A high signal as then cycled through the rows and then the keypress is located based on which column goes high when which row is high. Afterwards all rows are returned to the initial high state. After any commands to the LCD, all rows are written high again to ensure that no odd behavior occurs on the LCD, and keypress detection still functions. The resistors on the right of the diagram are the 2k ohm pulldowns for the column inputs to the Arduino, and the resistors on the left for the voltage divider that (as I mentioned earlier) can be replaced with a potentiometer if one wishes to do so.
Step 2: Code
I've attempted to comment this code extensively, but if anything in it remains unclear, please do ask! I've attached the .ino file to make uploading the code simple.
Note: I wrote this code before I had a handle on Object-Oriented Programming, and so the structure and organization of the code could certainly be better, but it still does function perfectly. I would update the code, but I no longer have the hardware on-hand and so would not be able to test it sufficiently. It is my hope, however, that the lack of OOP will make the code simpler to follow for Arduino beginners.
Step 3: Finished!
1 Person Made This Project!
- vinaybhogal1518 made it!