​ ​ ​ ​ Toggle
Results 1 to 3 of 3

Thread: Toggle

  1. #1

    Default Toggle

    I just discovered that TOGGLE can only be applied to an output pin. I was using it with a bit variable.

    There was no syntax error but neither was it altering the variable.
    I can use bit = bit + 1; TOGGLE was more readable.

  2. #2
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    24,299

    Default

    The TOGGLE command does indeed only affect an output pin.

    Which output pin depends on the value in the variable used; for a bit variable it will only be 0 or 1, and thus B.0 or B.1 output will be toggling, or C.0 or C.1 if an 8-pin PICAXE.

    The variable itself won't be changed. Using "bit = bit ^ 1" is my preference to invert a bit but +1 or -1 works just as well.

  3. #3
    Technical Support
    Join Date
    Jan 1970
    Location
    Bath,UK
    Posts
    6,456
    Blog Entries
    1

    Default

    'toggle bit3' is valid syntax, but won't do what you want.

    If bit3 is currently high, it will 'toggle 1' and if low it will 'toggle 0'. So output pin B.1 or B.0 would change!
    PICAXE Technical Support

Bookmarks

Posting Permissions

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