This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

having a problem

hi every one,
i m new in keil compiler. i connect LCD16x2 and keypad (4x4). my problem is that , in LCD, it can show from 0-15 on pressing from first till last key, while i want to print what is exactly written in keypad. like 1-9, 0, A to D.?
my second problem is that i can see the number only while pressing, i want that pressed no. to show untill i press new no.?
and third problem is that,i want to save the pressed digits from key pad , to send them wirelessly too, but thats a later task, first i need to save the digits in any variables.
many thinks and regards to all, plz waiting for the reply
my code is in c:\projects\hamash\keilcpp\55

Parents
  • In your main loop, after read a key , you should compare to an old key. If NEW key != OLD key then you have new key pressed. Otherwise, either same key pressed or no new key pressed.

    Let have a variable called OldVar1.
    Then your main loop looks something like this:

    main()
    {
      var1 = INKEY();      // IS function INKEY returns 0-15
    
      if (var1 != OldVar1)   // CHECK THE SYNTAX FOR C
                                            // Print on LCD only have a new key pressed
      {
          Key = LOOKUP[255,1,2,3,"A",4,5,6,"B",7,8,9,"C","*",0,"#","D"][var1];
          PrintAt(2,1,var1,"grate coder");
          OldVar1 = var1   // Save the key value for later
      }
      delayms(100);
    
     goto main
    }
    
    I write program in hyfan-basic, but the logic is same as c
    
    Tom
    
    
    

Reply
  • In your main loop, after read a key , you should compare to an old key. If NEW key != OLD key then you have new key pressed. Otherwise, either same key pressed or no new key pressed.

    Let have a variable called OldVar1.
    Then your main loop looks something like this:

    main()
    {
      var1 = INKEY();      // IS function INKEY returns 0-15
    
      if (var1 != OldVar1)   // CHECK THE SYNTAX FOR C
                                            // Print on LCD only have a new key pressed
      {
          Key = LOOKUP[255,1,2,3,"A",4,5,6,"B",7,8,9,"C","*",0,"#","D"][var1];
          PrintAt(2,1,var1,"grate coder");
          OldVar1 = var1   // Save the key value for later
      }
      delayms(100);
    
     goto main
    }
    
    I write program in hyfan-basic, but the logic is same as c
    
    Tom
    
    
    

Children