Shop OBEX P1 Docs P2 Docs Learn Events
Variables between Cogs — Parallax Forums

Variables between Cogs

PropDevPropDev Posts: 2
edited 2010-07-13 17:41 in Propeller 1
Hello,

I'm trying to figure out how to update a variable between 2 cogs. For example, lets say I have a method running in a new cog that blinks an LED at a certain speed. In my main method running in the default cog I want to update the variable that controls the speed at which the LED blinks.

Firstly, is this possible? If so, how is it done?

I'm programming in Spin.


Thanks

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2010-07-13 17:23
    Every global variable that is defined in a VAR-section of a spinfile can be accessed even ACROSS cogs

    so if the name of your variable would be blink_rate

    you simply code

    blink_rate := 15

    and you are done

    only global variables that are defined in another spin-file (= another object) are not directly accessible

    best regards

    Stefan
  • PropDevPropDev Posts: 2
    edited 2010-07-13 17:41
    Wow thank you. I thought I tried that but something else must have been different. I got the program working now.
Sign In or Register to comment.