Hi, i heard that you can write the code of keypad to arduino using analog input, may i know how this done? and if there are any examples that i can use?
Sure, you make a string of resistors from +5 to ground. Attach the middle of the string to an analog input.
Then, grounding the junction of 2 resistors one at a time will change the analog voltage read in. You poll the analog input and when you see change from the non-button push reading you know a button was pushed.
There was a great example of this from a fellow in Spain in the old forum.
You may have luck searching for Spanish analog button or similar.
Maybe one button keypad.
I found this link that might be helpfull: http://www.instructables.com/id/Arduino-3-wire-Matrix-Keypad/
I really dont know, but would like to, if the values of the resistors can be changed and how do you calculate them.
Regards
String ten 1K resistors in series from 5V to Gnd, R10 to R1, R10 at 5V and R1 at Gnd.
Connect the junction of R9 & R10 (call this spot J9) to an analog input.
J1 = junction of R1/R2. Each Jx will be a button going to ground.
J2 = junction of R2/R3, etc.
Now you have a simple voltage divider where Vout = R2/(R1+R2),with R2 being the resistors between J9 and Gnd, and R1 being the Resistor above J9.
You can then make a simple excel spreadsheet that will calculate the voltage J9.
With no buttons pressed, J9 = 5*(R1+R2+R3+R4+R5+R6+R7+R8+R9)/* ((R1+R2+R3+R4+R5+R6+R7+R8+R9)+R10) )
more simply written as 5*sum(R1:R9)/sum(R1:R10)
With J9 pressed, J9 = 0V
With J8 pressed, J9 = 5*(R9)/(R9+R10)
J7 pressed, J9 = 5sum(R8:R9)/sum(R8:R10)
J6 pressed, J9 = 5sum(R7:R9)/sum(R7:R10)
J5 pressed, J9 = 5sum(R6:R9)/sum(R6:R10)
J4 pressed, J9 = 5sum(R5:R9)/sum(R5:R10)
J3 pressed, J9 = 5sum(R4:R9)/sum(R4:R10)
J2 pressed, J9 = 5sum(R3:R9)/sum(R3:R10)
J1 pressed, J9 = 5*sum(R2:R9)/sum(R2:R10)
With 1K resistors, values should be:
J9 pressed = 0
J9 open = 4.5V
J8, 2.5
J7, 3.333333333
J6, 3.75
J5, 4
J4, 4.166666667
J3, 4.285714286
J2, 4.375
J1, 4.444444444
With the excel spreadsheet, you can play with different values easily and see if you can find a spread that you like better.
Example & spreadsheet to go with the above.
http://www.crossroadsfencing.com/keypad_divider.xls