Keypad_Lcd problem


Closed Thread
Results 1 to 6 of 6
  1. #1

    Default Keypad_Lcd problem

    Hi everyone,
    Kindly check the codes below, I'm trying to display numeric value to the LCD 1 to 12.
    My problem is that initially it displays the digit 4 and I noticed that switches 1-3(row 1) dont change any value (displays digit 4).
    But switches 4 to 12 is working fine. I'm using PIc16F876A, my keypad is 3x4 and connected to B0-B6 with external resistors 270 ohms at B0-B3.
    My second question is how do you convert this code 'LCDOUT $FE, $C0, "ROW=", DEC ROW, " COL=", DEC COLUMN, " SW=", DEC SWITCH, " " and
    LCDOUT $FE, $80, "ROW=",BIN4 (BUFFER & $0F)," COL=", BIN4 BUFFER >>4' to Serout command.

    The Code:
    ;define the variables
    BUFFER VAR BYTE
    ALPHA VAR BYTE ;counter for rows
    COLUMN VAR BYTE
    ROW VAR BYTE
    SWITCH VAR BYTE

    ;SET UP PORT B PULL UPS
    OPTION_REG.7 = 0 ;Enable PORTB pullups to make B4-B7 high
    TRISB = %11110000 ;Make B4-B7 inputs, B0-B3 outputs,
    TRISC =%00000000
    PAUSE 200 ;Wait for LCD to start
    ;Set up the initial LCD readings
    Serout 7,6, [$FE, 1] ;Clear the LCD
    PORTB =%00001110 ;Set line B0 low so we can read row 1 only
    LOOP:
    PORTB =%00001110 ;Set line B0 low so we can read row 1 only
    FOR ALPHA = 1 TO 4 ;Need to look at 4 rows
    IF (PORTB & $70)<>$70 THEN
    ;As soon as one of the bits in B4 to B7 changes we
    ;immediately
    ;have to store the value of PORTB in a safe place.
    BUFFER =PORTB
    GOSUB SHOWKEYPRESS
    Serout 7,6, [$FE, 1] ;Clear the LCD

    ELSE
    ENDIF
    PORTB= PORTB <<1 ;move bits left one place for next line low
    PORTB= PORTB + 1 ;put 1 back in LSBit, the right bit
    NEXT ALPHA
    GOTO LOOP

    SHOWKEYPRESS:
    BUFFER = BUFFER ^ %11111111 ;flips all the bits in the buffer
    ;print the first line
    ''LCDOUT $FE, $80, "ROW=",BIN4 (BUFFER & $0F)," COL=", BIN4 BUFFER >>4

    COLUMN=(NCD BUFFER) -4
    ROW=NCD (BUFFER & $0F)
    SWITCH=((ROW-1) * 3) +COLUMN
    ;print the second line
    ''LCDOUT $FE, $C0, "ROW=", DEC ROW, " COL=", DEC COLUMN, " SW=", DEC SWITCH, " "
    Serout PortC.1,6,[$FE,1]
    serout PortC.1, 6, [#SWITCH]
    pause 500
    RETURN
    END


    Thanks in advance,
    joe

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    this could be easier to debug and implement
    http://www.picbasic.co.uk/forum/showthread.php?t=3250

    Download the latest version
    http://www.picbasic.co.uk/forum/atta...2&d=1181850086
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3

    Default

    Hi Steve,
    Thanks for the reply, I know it may sound silly but where can I get MPASM to compile the keypad.bas? Sorry, I'm really new to this found hobby.


    Thanks again,
    joe

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    No problem my friend, you're in the learning process.

    To have MPASM (and some extra tools) just Download MPLAB IDE from Microchip Website.
    http://www.microchip.com/stellent/id...&part=SW007002

    If you're using MicroCodeStudio, you need to specify you want to use MPASM as assembler in View>Compile and Program Option>>Assembler.

    If you don't want to download MPLAB, you can use Darrel's version made for PM, same thread, post #29
    http://www.picbasic.co.uk/forum/show...3&postcount=29
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5

    Thumbs up

    Hi Steve,
    Thanks for the guide, everything now is running fine...


    Regards,
    joe

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. problem using GOSUB under interrupt
    By fobya71 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th March 2010, 19:52
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  3. Microcode Studio 18f2455 problem?????
    By volkan in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 21st May 2007, 21:04
  4. Hardware problem or what ?
    By Steve S. in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 4th March 2007, 21:39
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts