Button subfunction 16F628


Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Jul 2005
    Posts
    18

    Default Button subfunction 16F628

    Here I go again :-)

    I am trying to display some values on an lcd. One that counts from 10 to 20 using up\down buttons. And when I press RB1 the lcd counts from 80 - 90 using the same up\down. I created the dummy functions because I found that having these allowed me to hold the button and have continous incrementation\decrementation (see code below). Ive connected RA4 and RA1 to ground.

    My problem is that I want to solely increment\decrement num2 without interfering with num1. The other problem is that when I press RB1 to go num2 mode, the lcd counts up on its own. If anyone has a look at my grubby code and sees what Im trying to do and where Im doin wrong, can you shead some light please?

    Muchas Gracias


    Juan






    ************************************************** ******
    Include "modedefs.bas" ' Include serial modes
    DEFINE BUTTON_PAUSE 75 ' button debounce delay is 75ms

    I con 254 '254h = 1111 1110 (Sets LCD to command mode)
    ClrScr con 1 '01h = 0000 00001 (Clears Screen & goes to position 1)
    Line2 con 192 'COh = 1100 0000B (sets address to positionn 40 on LCD)
    DispCur con 12 '12h = 0000 1100 (activates display & cursor mode)
    'Commands obtained from LCD article in epemag.com

    B0 var byte
    B1 var byte
    B2 var byte
    B3 var byte
    B4 var byte
    number var word
    number2 var word

    B0 = 0
    B1 = 0
    B2 = 0
    B3 = 0
    B4 = 0

    number = 15
    number2 = 85

    serout PORTB.0,T9600,[i,clrScr] ' Clearscreen
    pause 400

    numSetup:
    serout PORTB.0,T9600,[I,128,"Display num1"] ' Setup display
    serout PORTB.0,T9600,[I,line2," Press button"] ' Setup display
    numMain:
    pause 25
    Button PORTA.7,1,200,255,B0,1,incNum
    Button PORTA.6,1,200,255,B1,1,decNum
    Button PORTA.4,1,200,255,B0,1,dummy1
    Button PORTA.1,1,200,255,B1,1,dummy2
    Button PORTB.1,1,200,255,B2,1,number2Setup
    Serout PORTB.0,T9600,[i,line2,#number]
    goto numMain

    incNum:
    if number > 19 then numMain
    number = number + 1
    pause 100
    Goto numMain ' goes back to main function

    decNum:
    if number < 11 then numMain
    number = number - 1
    pause 100
    Goto nummain ' goes back to main function

    dummy1:
    PAUSE 1000
    GOTO nummain
    dummy2:
    PAUSE 1000
    GOTO nummain

    number2Setup:
    serout PORTB.0,T9600,[i,clrScr] ' Clearscreen
    serout PORTB.0,T9600,[I,128,"Display num2"] ' Setup display
    number2Main:
    pause 25
    Button PORTB.7,1,200,255,B3,1,incNumber2
    Button PORTA.6,1,200,255,B4,1,decNumber2
    Button PORTB.1,1,200,255,B2,1,numsetup
    serout PORTB.0,T9600,[I,line2,#number2]
    goto number2Main

    incNumber2:
    if number2 > 89 then number2Main
    number2 = number2 + 1
    pause 100
    Goto number2main

    decNumber2:
    if number2 < 81 then number2main
    number2 = number2 - 1
    pause 100
    Goto number2main
    Last edited by Jųan; - 11th August 2005 at 01:25.

Similar Threads

  1. Sony SIRC IR Issue
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th August 2015, 08:10
  2. Button problem driving me crazy!! Please help!
    By bearpawz in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 20th November 2007, 14:46
  3. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43
  4. Code check -- button not working
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 2nd March 2006, 22:43
  5. Button Push within 3 second Window
    By Tissy in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd December 2005, 10:06

Members who have read this thread : 0

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