From 0ebab9603e509864477ecbca5274f2399b22916e Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Wed, 6 Jan 2016 16:37:14 +0000 Subject: [PATCH] Blink-IO.js: Call the function after declaring it This works ok if executing the whole file but the node.js interactive interpreter gets confused when yoy copy and paste the code Signed-off-by: Brendan Le Foll --- examples/javascript/Blink-IO.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/javascript/Blink-IO.js b/examples/javascript/Blink-IO.js index 64eb788..75f080c 100644 --- a/examples/javascript/Blink-IO.js +++ b/examples/javascript/Blink-IO.js @@ -29,11 +29,12 @@ var myLed = new m.Gpio(13); //LED hooked up to digital pin 13 (or built in pin o myLed.dir(m.DIR_OUT); //set the gpio direction to output var ledState = true; //Boolean to hold the state of Led -periodicActivity(); //call the periodicActivity function - function periodicActivity() { myLed.write(ledState?1:0); //if ledState is true then write a '1' (high) otherwise write a '0' (low) ledState = !ledState; //invert the ledState setTimeout(periodicActivity,1000); //call the indicated function after 1 second (1000 milliseconds) } + +periodicActivity(); //call the periodicActivity function +