Shop OBEX P1 Docs P2 Docs Learn Events
VAR — Parallax Forums

VAR

Armored CarsArmored Cars Posts: 172
edited 2004-11-18 04:35 in BASIC Stamp
Will this work

cat VAR IN4

or do I need something like this

car VAR IN4.Bit1

I looked in help but it wasnt very clear.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-17 20:45
    That will work, and cat will be defined as a bit-sized variable that will follow the state of P4 (make sure that P4 is an input, else it won't change).
    In PBASIC 2.5 an easier way to do that is:

    {$PBASIC 2.5}  
    Cat    PIN    4
    Dog    PIN    5
     
    Setup:
      OUTPUT Dog
     
    Main:
      Dog = Cat
      PAUSE 100
      GOTO Main
      
      
    

    In this program Cat and Dog names assigned to P4 and P5, respectively.· On reset, all pins are inputs, so Dog (P5) is made an output.· The main loop causes the output from Dog to follow the input from Cat.· The equivalent code is:


    Main:
      OUT5 = IN4
      PAUSE 100
      GOTO Main
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • Armored CarsArmored Cars Posts: 172
    edited 2004-11-18 01:22
    Will this also work?

    drive PIN 0

    forward CON 500

    MAIN:

    PULSOUT drive, forward

    PAUSE 20

    GOTO MAIN
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-11-18 04:35
    Yes it will. The compiler looks at the context in which you use a PIN defintion and will substitue the correct values or register bit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.