You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • Who is status defined? ...as global variable? - I'm not aware of STATUS begin reserved or used by definition. Running 1v85 and - fortunately ;-) on a PICO and not a 411 - it just does the right thing... even without declaring STATUS (B2 = LED = LED1 - the red one - on PICO).

    STATUS=B2; var myVar = 32; digitalWrite(STATUS,1);
    setTimeout("digitalWrite(STATUS,0)",1000);
    console.log(STATUS);
    console.log(myVar);
    

    The LED behavior - 1 sec on '@' upload - and console output are as expected:

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v85 Copyright 2016 G.Williams
    >echo(0);
    B2
    32
    =undefined
    > 
    

    And so is it with some more code which does what you intend to do:

    console.log(B2,LED,LED1);
    STATUS=B2; var myVar = 1; digitalWrite(STATUS,myVar);
    console.log(STATUS);
    console.log(myVar);myVar = 0; setTimeout("digitalWrite(STATUS,myVar)",1000);
    console.log(STATUS);
    console.log(myVar);
    

    Console output:

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v85 Copyright 2016 G.Williams
    >echo(0);
    B2 B2 B2
    B2
    1
    B2
    0
    =undefined
    > 
    

    Messing up... a 411 thing?

    The code STATUS=C0; // in my case STATUS=B2; is actually not redefining a pin... it is just implicitly creating a variable and let it point to the pin mentioned on the right side...

About

Avatar for allObjects @allObjects started