Continue to Site

# USER INTERFACE:1 enter/settings switch,2switches->2digit

Status
Not open for further replies.

#### fantabulous68

##### Junior Member level 2
how to enter in switch

I want to create a user interface using C programming for a pic microcontroller-see attached picture.

It will have 3 pushbutton switches. It will allow the user to enter a 2 digit value:

1.enter/settings switch

2.increase digit from 0 to 9

3.decrease digit from 9 to 0

If the user pushes the settings button then the user will go to a settings screen. The user can then select a 2 digit value EG. 99 or 34. The user can use the increase button to increase the first digit from 0 to 9 and 0 to 9 again. The first digit will be displayed on the LCD whilst the user is increasing. Thereafter the user can use the decrease button to decrease the second digit from 9 to 0 and 9 to 0 again. The second digit will be displayed on the LCD whilst the user is decreasing. So now the user has decided on a 2 digit value and wants to use this value in another function so the user presses ENTER and leaves the Settings screen.

Any1 with any useful ideas to approach this.

Code:
main()
{

int i;
TRISB= 0xFF;

i=0;
j=9;
while (1) {
//wait for press

while (RB6); 		 // loop  (1)
DelayMs (30);  	          //debounce

//wait for release

while (!RB6);		//loop(2)
DelayMs(30);		 //debounce
i++;

//wait for press

while (RB4); 		 // loop  (1)
DelayMs (30);  	          //debounce

//wait for release

while (!RB4);		//loop(2)
DelayMs(30);		 //debounce
j--;

}

how do i combine those digits to use as a numerical number in another function, shud i use a concatination function?

Re: USER INTERFACE:1 enter/settings switch,2switches->2di

Hello Fantabulous68!
Last year i also faced the same problem while designing a 8051 based visitor counter in it i had to set the limit of te number of people entering the room by using two push buttons and the algorithm was the same that the user had to set the tens digit and then the ones digit. I googled a lot and then i found a function (dont remember where but i guess it was 8052.com) which was used to convert two separate four bit numbers to 8 bit number it used some sort of mathematics and was working fine you just google around and if you find the function just use the mathematics in it and use it for your pic and when you're using c then coding is no problem.
Good Luck!

Re: USER INTERFACE:1 enter/settings switch,2switches->2di

thanks alot 4 dat sk_008. I will check it out for sure

Status
Not open for further replies.