Intro: Arduino Phone Book
Ever wanted to have a Phone Book, controlled using a microcontroller, which is very easy to use, and you can use it while talking on phone, and is saving data on SD Card? then this instructable is for you. In this instructable you will learn how to make an arduino controlled Phone Book, and you can control it using only four buttons (Up, Down, Left, Edit), in this instructable you will also learn how to use LCD displays and how to store data on SD Cards.
Step 1: Parts
For this project you will need:
- Arduino UNO (Any ATmega based board will work, other boards will have different pins)
- SD Card (you can use any sd card but you must have SD Card adaptor)
- 8x2 LCD Display
- Jumper wires
- Variable Resistor (to adjust contrast on LCD)
- 4x Pushbuttons
- 4x ~100nF capacitors
- 4x 1kOhm Resistors
- 3x 4.7kOhm resistors
- 3x 10kOhm resistors
- 1x 100Ohm resistor
- 1x power plug
- 1x diode (optional)
- 1x On/Off switch
- 1x Box
Step 2: Some Info About Liquid Crystal Displays
Liquid Crystal Displays have many uses, they can be used in televisions, computers or other electric devices, they are also really easy to use. There are also many sizes of them, for example 20x2 (Note size AxB means A columns and B rows), 10x4 and so on, in this project I have used 8x2 LCD. So, Liquid Crystal Display Modules have 14 pins (but in this tutorial we need only 10, and only 6 pins go to arduino board), and 2 other pins (Anode +4.2V (you can connect it to +5V with 100 ohm resistor) and Cathode (Ground)) for LCD Backlight. So LCD pinout looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Gnd +5V V0 RS R/W E D0 D1 D2 D3 D4 D5 D6 D7
(In images look at LCD wiring schematic)
Pin 1: Ground Pin
Pin 2: +5V Pin.
Pin 3: contrast adjust pin, and it goes to potentiometer
Pin 4: is Register/Select Signal pin and it goes to arduino's pin 7 (you can use any I/O pin)
Pin 5: is Read Write pin, in other words if it's set to HIGH then it's in Read mode but if it's set to LOW it's Write mode, because we only want to write on LCD we can just connect it to ground.
Pin 6: is Enable Signal Pin and it goes to arduino pin 6.
From Pin 7 to Pin 14: Data pins but we only need pins from 11 to 14.
So connect LCD Pins to Arduino Like that:
Pin 11: to Arduino pin 5
Pin 12: to Arduino Pin 4
Pin 13: to Arduino Pin 3
Pin 14: to Arduino Pin 2
Pin 15: Anode Pin, Connect to +5 V with 100 ohm resistor (Warning: Do not forget this resistor, otherwise you will damage your LCD)
Pin 16: Cathode Pin, Connect it to Ground
After Wiring is done you can connect your arduino to your computer and open new example sketch (File -> Examples -> LiquidCrystal -> Hello World), after opening sketch, before loop() you will notice this:
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Change these numbers to this: (7, 6, 5, 4, 3, 2) (These numbers are I/O Pin numbers that are connected to LCD. Example: LiquidCrystal lcd(RS, E, D4, D5, D6, D7)) (NOTE: We are using this project also uses SD Card and SD Card only works at 13, 12, 11, 10 pins)
Step 3: Some Info About SD Cards
SD memory cards are mostly used in mobile phones and cameras. They are small and easy to use, and they have really large memory. Arduino also have internal memory called EEPROM, but it's to small to store large data, so instead of EEPROM I have used SD Card to create this project. SD Cards come in different sizes, and each one have it's on "socket", to connect SD Card to arduino you will need a SD Card module, but if you don't have one you can make your own (See Image 3, but you will also need a SD Card adaptor). The only problem is that SD Cards work at +3.3V but Arduino UNO (and other ATmega based boards) work at +5V, So to solve this problem you can make voltage dividers using resistors. As you can see on schematic you can use 4.7 kOhm and 10 kOh, resistors as a voltage divider (if you don't know what voltage dividers are, here's some info about them: voltage dividers basically decrease voltage, and the amount of which the voltage decreases is "proportional" to the value of the resistors, here's simple equation which shows what your output voltage will be: V_out = (R2)(R1+R2) V_in, where R1 is resistor on input, R2 is resistor connected to ground and V_in is input voltage, so on SD Card R1 is 4.7 kOhm, R2 is 10 kOhm and input voltage is +5 volts, after changing variables with numbers we will get that V_out is ~3.3 volts). So now wire up everything using schematic, and connect your arduino to your computer, and upload example SD sketch: File -> Examples -> SD -> CardInfo (make sure that you have changed chipSelect = 4; to chipSelect = 10; and your SD Card is either FAT16 or FAT32 otherwise you will have to format it with special program that lets you choose which "type" you want your SD Card to be), after uploading, open serial monitor, if everything is ok that means your wiring is correct and SD Card works, now try opening another ReadWrite sketch (File -> Examples -> SD -> ReadWrite), and try writing on SD Card, after uploading sketch, open serial monitor (Important NOTE: default CS Pin is 4, you have to change it to 10, you can do this by changing if(!SD.begin(4)) to if(!SD.begin(10)) ). After everything is done you can check SD Card on your computer, after connecting it you will notice new text file called text.txt, that means that your SD Card works and wiring is correct.
Step 4: Wiring
So the wiring is "simple", See schematic for circuit. Firstly Connect LCD (See step 3 for tutorial and testing), then Connect SD Card (See step 4 for tutorial and testing) and then connect button, you will need four buttons: Up, Down, Left, Right, four capacitors (I have used ~300 nF) for debouncing, and four ~1-10 kOhm resistor (you can use any resistor which value is greater that 1 kOhm) to ground connections. See bottom of this step to download Circuit, it's drawn in program called Fritzing, so in order to open it, you have to install this program, after opening you will see the circuit drawn on breadboard (I have used many breadboard to make it simple because on 1 big breadboard it would be harder to understand), you can click each resistor/capacitor and other parts to see it's value, or part name, After you will finish wiring, recheck everything, and if everything is ok then you can continue.
Step 5: Testing
Now, after finishing wiring, you have to test it and see if everything work fine. Firstly Download arduino sketch (see bottom of this step), then recheck your wiring, also make sure that your SD Card is formatted, then connect your arduino to your computer and upload the sketch. After uploading is done, on the screen you will see a message saying "Welcome", after few seconds you will see number zero on the display, it's index, try pressing Up/Down buttons, when you will press up number will increase by 1, if you will press down button it will decrease. (if it don't works try checking your wiring), now try pressing edit button, when you will press it you will see message saying "Edit Mode", after few seconds you will see same number on which you were when you have pressed edit button and underline next to it (it shows cursor position), now try pressing Up/Down buttons, when you will press Up button lcd will print A letter at cursor position, if you will press it again it will print B and so on, heres how the list looks like:
' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
So just choose first letter you want and then change cursor position, to do that you can press left button, example:
reconnect arduino to computer, set index to 0, click edit button, when you are in edit mode press Up/Down button, and choose letter 'N', then click left button, then choose letter 'u', then letter 'm', then letter 'b', then 'e', then 'r', then press left button until cursor will go down:
8x2 LCD ( '_' is the cursor position). LCD display should look like this
Now you can write numbers, it's same as writing letters, just press Up/Down button, the list looks like this:
' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
now try writing 0, then 1 then 2 until LCD Display looks like this
So after writing number 7 when you will click left button screen will move right allowing you to write more digits, try writing all digits, like that:
after writing number 9, click the left button again so the cursor is one "block" (character) away from 9 like this
where _ is cursor. then click edit button. you will see message saying "Saving...", and then it will display data written on index 0:
to scroll click left button.
Step 6: The Box
So now to make project look good we can put everything in a box, In this step you will need a large box so everything (Arduino and breadboard) would fit. We would also need a soldering iron, or a good knife to cut the box. So firstly find a place where you want your lcd to be, then put lcd on that place facing downwards (as shown on the picture) find a marker (or a pencil) and mark, then do same with buttons, On/Off switch and power plug.
Step 7: Cutting the Box
So after marking is done we can now cut box, to do this I have used soldering iron (Warning: You may damage your soldering iron's tip, I have sanded the tip after cutting but I don't recommend to use this method), but it's also possible to use very sharp knife (Warning: Be careful don't harm yourself). After cutting, clean everything, see pictures to see how the box should look like after cutting.
Step 8: Soldering
So now you have to solder some long wires to pushbuttons, to an on/off switch and to a power plug, for the wires I have used magnet wires, which are easy to find and cheap to buy. After soldering put them in the box (see pictures), and hotglue them in place, then put LCD display and hot glue it too. After everything is done we can connect LCD, buttons, on/off switch to a breadboard.
Step 9: Wiring Everything in the Box
So after soldering is done, and all parts are in place we can start wiring everything up, So power plug output are two wires, before connecting you have to check which one of it's wires is positive and which one is ground (negative), try connecting 9V battery and use multimeter, so after you have identified wires you can continue wiring. connect the positive wire to on/off switch's first wire and connect on/off switch's second wire to Arduino's Vin pin, connect negative (ground) wire of power plug to arduino's Gnd pin (Warning: Add a diode to Arduino's Vin pin, because if you will reverse polarity you will damage your arduino). If you want you can also download the circuit:
Step 10: Finishing
So to finish project, add cover and write labels on buttons, and you can also add arduino sticker. Then connect your 9V battery to it, and try clicking buttons, If you will get error saying Error: SD Card, it means that your SD Card isn't connected corrently, or isn't FAT16 or FAT32, try rechecking your wiring. If you will find any error in code please post it in comments