- This topic has 1 reply, 2 voices, and was last updated 8 years, 3 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
|
Microcontroller › PIC › Input text in array with push button.
Dear Sir,
Can you please guide me how to enter text in an array with simple 4 push button and save that array in an internal eeprom of pic16f877a.
First buttton to increment character, Second button to decrement character, third button to shift cursor and fourth button to save the data in eeprom.
Thanks,
Sujit Mishra
Hi Sujit
I don't know how to work with a PIC but I can surely help you with the logic behind this kind of code.
Lets make it simple by using if-else instructions to check which button has been pressed and then perform the respective task. The code would be somewhat like this:
first of all declare all variables to be used, like
integer variable (say int i=0,j=64;) //characters' ASCII value start from 65=90, check it out.
character string (say char arr[10]
if(button 1 pressed)
{
if(j==90) //char is 'Z'
{j=65} //char becomes 'A'
else
{j++;} //increment char
arr=j; //put char value in string's ith position
}
else if(button 2 pressed)
{
if(j==65 || j==64) //char is either 'A' or its ASCII value is 64
{j=90} //char becomes 'Z'
else
{j–;}
arr=j;
else if(button 3 pressed)
{
i++; //increment string's position
}
else if(button 4 pressed)
{
arr[i+1]=''; //close the string with a null character
i=0; //reset i's value to 0
//also here you should include a code which will store this string on eeprom of PIC
}
You can adjsut the string size according to your need and look out for some code that will help you to store string in eeprom. Try searching out at EGs search bar (top right corner).
You can also write a code to print this process on LCD, just add the LCDdisplay() lines just after if-else instructions.
This might hlep you. Good luck!!