View previous topic :: View next topic |
Author |
Message |
zephyr2009
Joined: 06 Aug 2010 Posts: 15
|
Saving cellphone numbers on PIC16f877a using keypad and lcd |
Posted: Fri Aug 13, 2010 11:32 pm |
|
|
Could that be possible?
I have here codes for inputting number from keypad that will be outputted on LCD but I have no idea on how to save the numbers into PIC that I inputted on my keypad.
And after that, all cellphone numbers on PIC16F877A should be called by GSM to be able to transmit messages to recipients.
Do you have codes for this or threads? Please help me. |
|
![](templates/subSilver/images/spacer.gif) |
theasus
Joined: 31 May 2009 Posts: 79
|
|
Posted: Sat Aug 14, 2010 12:19 am |
|
|
You can use external EEPROM like 2408 to save the numbers. You can find its library form PICC/Drivers. And it is very easy to use. Here are the codes which is enough for your program:
Code: |
#include <input.c> //
#include <2408.c> // necessary libraries
#use i2c(master,sda=pin_c4,scl=pin_c3,slow=100000)// sets I2C communication parameters
write_ext_eeprom(long int address, BYTE data);\\Write data to address
variable=read_ext_eeprom(long int address);\\Read the adress and assign its value to variable.
|
And also you can use these codes for keypad driving:
http://www.ccsinfo.com/forum/viewtopic.php?t=28022&start=14 |
|
![](templates/subSilver/images/spacer.gif) |
zephyr2009
Joined: 06 Aug 2010 Posts: 15
|
|
Posted: Sat Aug 14, 2010 9:15 am |
|
|
I have here my driver for 3x4 keypad...
Code: | ///////////////////////////////////////////////////////////////////////////
//// Flex_KBD.C ////
//// Generic keypad scan driver ////
//// ////
//// kbd_init() Must be called before any other function. ////
//// ////
//// c = kbd_getc(c) Will return a key value if pressed or /0 if not ////
//// This function should be called frequently so as ////
//// not to miss a key press. ////
//// ////
///////////////////////////////////////////////////////////////////////////
//Keypad connection:
#define col0 PIN_B5
#define col1 PIN_B6
#define col2 PIN_B7
#define row0 PIN_B1
#define row1 PIN_B2
#define row2 PIN_B3
#define row3 PIN_B4
// Keypad layout:
char const KEYS[4][3] = {{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}};
#define KBD_DEBOUNCE_FACTOR 33 // Set this number to apx n/333 where
// n is the number of times you expect
// to call kbd_getc each second
void kbd_init() {
}
short int ALL_ROWS (void)
{
if (input (row0) & input (row1) & input (row2) & input (row3))
return (0);
else
return (1);
}
char kbd_getc( ) {
static byte kbd_call_count;
static short int kbd_down;
static char last_key;
static byte col;
byte kchar;
byte row;
kchar='\0';
if(++kbd_call_count>KBD_DEBOUNCE_FACTOR) {
switch (col) {
case 0 : output_low(col0);
output_high(col1);
output_high(col2);
break;
case 1 : output_high(col0);
output_low(col1);
output_high(col2);
break;
case 2 : output_high(col0);
output_high(col1);
output_low(col2);
break;
}
if(kbd_down) {
if(!ALL_ROWS()) {
kbd_down=false;
kchar=last_key;
last_key='\0';
}
} else {
if(ALL_ROWS()) {
if(!input (row0))
row=0;
else if(!input (row1))
row=1;
else if(!input (row2))
row=2;
else if(!input (row3))
row=3;
last_key =KEYS[row][col];
kbd_down = true;
} else {
++col;
if(col==3)
col=0;
}
}
kbd_call_count=0;
}
return(kchar);
}
|
Is there anything else that i will change on your code?
and is it possible to embed your code with this keypad driver? |
|
![](templates/subSilver/images/spacer.gif) |
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
Posted: Sat Aug 14, 2010 10:18 am |
|
|
If the PIC you're using (which you didn't mention) has EEPROM (and some do!) built in, you can use that.
If the PIC doesn't have EEPROM, but is one of the devices with internally reprogrammable flash (like I think most if not all of the PIC18F series), you can actually use a block of flash memory to save your defaults.
Last, if none of the previous two are options, you can use an SPI, I2C or even Dallas 1-wire NVRAM/EEPROM/FLASH device.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
![](templates/subSilver/images/spacer.gif) |
zephyr2009
Joined: 06 Aug 2010 Posts: 15
|
|
Posted: Sat Aug 14, 2010 10:02 pm |
|
|
Quote: | If the PIC you're using (which you didn't mention) has EEPROM (and some do!) built in, you can use that.
If the PIC doesn't have EEPROM, but is one of the devices with internally reprogrammable flash (like I think most if not all of the PIC18F series), you can actually use a block of flash memory to save your defaults. |
I think that my PIC16F877A has an EEPROM because you can put codes into it. But I don't know on how to declare the numbers seen on LCD to be saved on PIC when I pressed the asterisk button (*) on KEYPAD 3X4 or something else. |
|
![](templates/subSilver/images/spacer.gif) |
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
Posted: Sun Aug 15, 2010 11:40 am |
|
|
zephyr2009 wrote: |
I think that my PIC16F877A has an EEPROM because you can put codes into it. But I don't know on how to declare the numbers seen on LCD to be saved on PIC when I pressed the asterisk button (*) on KEYPAD 3X4 or something else. |
To quote an old friend's measurement product line's mantra, "Don't Think, Know."
The 16F877 has 256bytes of EEPROM.
You could define an array of X number of phone numbers and then use the CCS functions write_eeprom and read_eeprom to save the data to the internal EEPROM.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
![](templates/subSilver/images/spacer.gif) |
zephyr2009
Joined: 06 Aug 2010 Posts: 15
|
|
Posted: Tue Aug 17, 2010 7:54 am |
|
|
mr. bkamen, I know that it is possible to save number on PIC16f877a,
im just a complete newbie with write_eeprom
do you threads for saving numbers what I declared on keypad and appeared on LCD.. I want to declare (*) on keypad when im done with my number and i want to save those numbers on PIC ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
Posted: Tue Aug 17, 2010 1:01 pm |
|
|
zephyr2009 wrote: | mr. bkamen, I know that it is possible to save number on PIC16f877a,
im just a complete newbie with write_eeprom
do you threads for saving numbers what I declared on keypad and appeared on LCD.. I want to declare (*) on keypad when im done with my number and i want to save those numbers on PIC ![Smile](images/smiles/icon_smile.gif) |
I usually make a config structure and then save that whole structure to EEPROM.
Do you have a book on 'C' yet? _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
![](templates/subSilver/images/spacer.gif) |
|