-
• #2
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... -
• #3
I was first thinking about a problem with the compiler (or "code footprint minimizer") integrated within the Espruino Web IDE, but according to your kind experiments this seems to work perfectly on a Pico.
I wonder why this issue could come from the Nucleo 411.... -
• #4
Guilty...
It seems that it is too late for me to write code... :-/I explicitely wrote
myVar=STATUS
somewhere at the bottom of my script. Nothing related to Nucleo nor "code footprint minimizer", I apologize for having suspected them :-)And thank you @allObjects for your help.
-
• #5
...yep, late so... as related to Zollikon/ZH, I wondered what you were up to that late... or early? - n/c needed... ;-)
-
• #6
You might want to review the BIND section at the bottom of the Performance page .
-
• #7
Thanks @CanyonCasa for the link, I didn't know the BIND mechanism!
Hi!
Is there a way to rename a pin? Let's say that a LED is mapped on
C0
, and is representing some kind of status of the device. I would like to do adigitalWrite(STATUS,x)
.I tried doing this:
STATUS=C0;
var myVar=32;
digitalWrite(STATUS,1);``
With this last example, when uploading the script to the Espruino (in my case this is right now the Nucleo-411 because each of my Espruinos are already in use) , it appears that
myVarequals
C0` !I suspect the
STATUS=C0
to be misunderstood by myself, right?