Menu

syntax error help

Help
2008-01-22
2013-05-30
  • Nobody/Anonymous

    I'm having problems with the syntax in my program.
    Idealy id like it to take 4 inputs and store them together as a single byte (with 4 leading 0's) but since i don't know how to do that im using each input to add to a variable (i). The syntax problem happens when i try to compile it. Check my only sub routine as it's whats causing the problem.

    'chip settings
    #chip 12F629, 4
    #config OSC = INT, BODEN = OFF, MCLR = OFF, PWRT = OFF

    'defines
    #define StartUpDelay 10 ms
    #define timeout 25 ms
    #define utime 1 s
    dim key byte 'this will be for later use, right now it does nothing

    #define bin1 GPIO.0
    #define bin2 GPIO.1
    #define bin4 GPIO.2
    #define bin8 GPIO.3
    #define bcheck GPIO.4
    #define latch GPIO.5

    'setting pin direction
    dir bin1 in
    dir bin2 in
    dir bin4 in
    dir bin8 in
    dir bcheck in
    dir latch out

    'dunno why i have this, but it's in the 12f629.txt file, so i left it here
    Startup:
           Wait StartUpDelay
          
    'main program
    Main:
    wait until bcheckp 'wait till a button is pressed
    wait timeout 'timeout sequence
    if not bcheckp then goto main 'if it's not presed, go back to main

    i = 0 'setting i=0, no problems with that

    Getkey 'running getkey sub routine

    'code below sets latch high
    if i = 11 then
    set latch on
    wait utime
    end if
    Goto Main

    'function to check if the button is pressed
    function bcheckp
    bcheckp = false
    if bcheck on then bcheckp = true
    end function

    'this is where i have my problems, help is appreciated
    sub Getkey
    if bin1 on then i+1 = i
    if bin2 on then i+2 = i
    if bin4 on then i+4 = i
    if bin8 on then i+8 = i
    end sub

     
    • Nobody/Anonymous

      shouldn't it rather be
      i = i + 1 ?
      At least this is the common form to assign a new value to a var.

      regards,
           Reelf

       
    • Nobody/Anonymous

      Thanks. It's been a long time since i tried programming (was using qbasic and win 3.1)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.