PDA

View Full Version : Pic16f877



GEORGE VARGHESE
- 29th April 2004, 19:57
I have a LAB77 board from Rentron.Pic Basic pro compiler from
M.E.Lab. At present when I switch on The display shows "press
any key".When I press any key this will display key value.
Now I need to enter a value 1000 to the memory.When I press
1 the value 1000 should increase by 1.
when I press 0 the value displays on the LCD should decrease by 1.
I need a program to do this function.

George

lwindridge
- 30th April 2004, 10:50
Can you post your code here so we can take a look?

Sounds like a simple case of loading the variable with a number before it goes through the main code.
Might be worth you taking a quick look in the PHP manual at the LET statement.

Hope that helps.

Leigh

GEORGE VARGHESE
- 30th April 2004, 11:34
Please go to
http://picbasic.com/resources/samples.htm#x1pbp

Then select keyx.bas

Here you can see the program to display key number on LCD.

When I press 1 and 2 together 1000 should appear on the
LCD display.

When I press 1 should increase by 1.
When I press 0 should decrease

lwindridge
- 1st May 2004, 08:19
OK, so what I need to know is...

1. Have you modified the code at all yet to try anything?
2. Are you using a keypad, and if so where is it connected.
3. If you are using a keypad, do you need access to any of the other buttons at all?

Based on this I should be able to come up with something for you.

Leigh

GEORGE VARGHESE
- 1st May 2004, 17:04
Please go to www.rentron.com/serkey16.htm
I have connected as shown in the diagram.

GEORGE VARGHESE
- 2nd May 2004, 17:25
Hello Leigh
I think we connect extra key as you adviced.
When it is in key scanning mode pressing any key it will show
key value.There is one more idea can we program for pressing
key number 1 and 2 together to go to the mode for displaying
1000 and should be able to decrease and increase by pressing
0 and 1.What is your opinion.If you have better idea please tell
me.
Regards
George

lwindridge
- 4th May 2004, 18:49
Looking at the code etc I can figure out the following...

If portb.0 = 1 then
cnt=cnt+1
endif
If portb.1 = 1 then
cnt=cnt-1
endif

So if the key attached to portb.0 is pressed then the variable cnt would reduce by 1 and would increase by 1 if the portb.1 key is pressed.

Using the example code you would reference the variable [key] and so could operate the same math based on the reading.

If you have modified the code already, please post it here and I'll make the modifications for you and place comments in the code so you understand more what it is doing.

Leigh