Calculator...Dual Mode??

Thread Starter

bse2013

Joined Jun 5, 2012
2
Hello Guys..
I am a bit new to microcontrollers and have a problem with the programming. I am making a calculator as a project using 16x2 LCD display and 4x4 keypad.. the circuit works fine and so does the proteus version...the problem i am facing is the dual mode version of the calculator...along with the calculations i want to run another feature on it but all my keypad keys are occupied and i can't seem to find a solution without damaging the part that works perfectly....so any help on how to program the keypad to switch when i press the key thrice or twice???
 

absf

Joined Dec 29, 2010
1,968
If I understood you correctly, you want the whole keyboard to mean something else (to remap the keyboard) when a certain function key is pressed and you're running out of extra keys, right?

In that case, there are 2 options to do it:

1. Long/short keypress. Just define one of the keys on the keyboard to have this function. When that key is pressed for more than 3 seconds, it would switch to the other mode. Normal keypress should not exceed 3 seconds.

2. Combination of 2 or 3 keys. Say you want to change mode just press "+,- and /" together. And indicate the mode on the LCD screen. When changing back, press the same keys combination again.

BTW, which mcu are you using?:)

Allen
 

absf

Joined Dec 29, 2010
1,968
Too bad, I have an example for the long/short keypress detection for 12F629 written by Randy Day. See if you can make use of the concept here...

Rich (BB code):
;Just air code. I'm using timer SFR names 
;from micros I use, so they may not apply 
;to the '675: 
Button_Loop 
        btfsc GPIO, 0 
        goto Button_Loop 
        ; enable 3 second timer here 
Short_Loop 
        btfsc GPIO, 0 
        goto  Short_Press 
        ; loop until timer expires 
        btfss   PIR1, TMR1IF 
        goto Short_Loop 
        ; if timer manages to expire, the 
        ; button is still pressed, 
        ; and is considered a 'long' (>3 sec) 
        ; press. 
        ; turn off timer here 
Long_Press      ; keep looping until button is released 
        btfss GPIO, 0 
        goto Long_Press 
        ; run your 'long press' code 
        goto Main_Program 
Short_Press 
        ; if gpio<0> went high before 1sec, 
        ; the button was released as a 'short' 
        ; (<3sec) press. 
        ; turn off timer here 
        ; run your 'short press' code 
        goto    Main_Program
Allen
 
Top