for loop #443
Replies: 13 comments
-
Posted at 2014-04-10 by @gfwilliams Hmm - thanks. It should be an easy fix. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-04-10 by @gfwilliams Ok - fixed for 1v61 :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-04-10 by Sacha Thank you. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-10-09 by user49129 If a js code breaks from a for loop as follows, the loop index i should not be changed! for(var i=0; i<10; i++) if(i==3)break; console.log(i) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-10-09 by @gfwilliams Thanks for letting me know. I've just fixed this, so it'll be in the 1v71 release of Espruino. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-20 by bigplik do you know how to use this for loop similar to way like Arduino ?
I was trying to use tutorial from buttons example, and change it a bit, like when I press the button LED1 will blink let say twice or triple times, in arduino modification it is easy, how to do it in espruino? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-20 by fdufnews Delay is not a good way to manage time dependant tasks as it uses all the resources for itself
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-20 by DrAzzy delay() is a scourge upon Arduino, and a plague that we are largely free from over here in Espruino-land. delay() is horribly overused on Arduino, and it's only simpler for very basic cases - as soon as you start making things more complicated, you end up in a mess. We have modern, sensible tools for non-blocking delays - setInterval(), setTimeout(), and setWatch() (for reacting to a pin change). All of those tasks on Arduino would either block, or require a "blinkWithoutDelay" type approach
vs Espruino:
or
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-20 by bigplik it's working, now I have equivalent to for loop operations ;), thank you fdufnews |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-20 by fdufnews Thanks! note that I have made a small correction to the code in order to prevent double launch of the blink sequence if it is already active. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-20 by bigplik cool, I had some counting problem when disconnected and connected board again, everything was working till I didn't use "save()" command and turned board off and back on, or disconnected and connected again, will check how it is going on now ;) fdufnews - everything is workin now, even after power of and on again the board, |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-20 by DrAzzy I fixed the code so it runs out of the box now - I had just omitted the definitions for the ledpin1/ledpin2 variables because I was illustrating how to write the code (just like how in the Arduino example, I didn't include definitions for the LED pins). I also missed the second argument to digitalWrite() in one case. Note that sometimes when copy/pasting code from these forums, it inserts non-printing junk characters. These get red-marked in the IDE, remove them where they appear. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-08-20 by bigplik DrAzzy, thank you, your code is also working now ;) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-04-09 by Sacha
Hi Gordon,
This for loop throws an error:
Is working on jconsole.com.
http://jsconsole.com/?for(i%3D0%2Cj%3D7%3Bi%3C10%3Bi%2B%2B%2Cj%2B%2B)%20%7B%20console.log(%27a%27)%3B%20%7D
Greetings
Sacha
Beta Was this translation helpful? Give feedback.
All reactions