Connect with us

Picaxe Program Variable Help

Discussion in 'Microcontrollers, Programming and IoT' started by Jasper.carpenter, Sep 23, 2019.

  1. Jasper.carpenter

    Jasper.carpenter

    3
    0
    Sep 23, 2019
    I am trying to make a variable increase every time a sensor senses something. I also want a button to reset the variable counter. I have been trying for a while but I still don't quite get it. This is the code I have so far.
    [mod edit: moved to to code box]
    Code:
    #no_data
    start:
    readadc c.0,b1
    readadc b.5,b3
    debug b0
    
    main:
    b2=0
    
    sensor:
    IF b1= 1 then b2=b2+1
    endif
    IF b3= 1 then goto start:
    goto sensor:
    I keep on getting syntax error at line 11 before position 15 (IF b1= 1 then b2=b2+1) saying 'Error: Expected a label not the variable B2'
    I have created a loading circuit and plugged the into the sensor, and I have a display but am not sure how to program that either. It would be much appreciated if someone could help me out.
     
    Last edited by a moderator: Sep 23, 2019
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    9,414
    1,925
    Nov 17, 2011
    According to the manual, pages 107/108 it looks like the single line structure can be used with goto or gosub only.
    Use a multiline structure as shown in the manual or e,g, here.
     
  3. Jasper.carpenter

    Jasper.carpenter

    3
    0
    Sep 23, 2019
    Thanks for that, I got it to work now, is there a way for me to display this on a 7 segment display?
     
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    9,414
    1,925
    Nov 17, 2011
  5. Jasper.carpenter

    Jasper.carpenter

    3
    0
    Sep 23, 2019
    How would you extend this to multi-digit displays, this link only shows for one digit.
     
  6. Harald Kapp

    Harald Kapp Moderator Moderator

    9,414
    1,925
    Nov 17, 2011
    By multiplexing.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-