• Your code is absolutely 'fine'. To verify, I used onboard red LED1 instead of D5 (false for initialization of toggle... more on that later).

    var toggle = false;
    function start() {
      setInterval(function() {
        toggle = !toggle;
        digitalWrite(LED1, toggle);
        console.log(toggle);
      }, 1000);
    }
    function onInit() {
      start();
    }
    

    You have nothing 'active / immediate' in your code that you upload. The code just defines several functions but nothing invokes any of them.

    onInit() ins only invoked when powering on (or pressing reset on Original board) - or saved.

    There is an option in the settings that saves the code automatically after upload (to cater to Arduino souls...).

    I assume, you entered the code in the right pane of the Web IDE - the editor - and uploaded it.

    After doing above, you enter in the left pane - the console - onInit() it works just fine what you have.

    My only recommended change in your code is to initialize toggle with true or false... which is perfectly understood as value by digitalWrite(). If you want to stay numeric - 0 / 1 - for you toggle, change line 4 to toggle = (toggle) ? 0 : 1;.

About

Avatar for allObjects @allObjects started