You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • D) Extend the program according to attachment 4 (1 in this post): Simple Blink with Sleep Indicator on Green LED

    For that purpose we use the very first time 'the real deal of programming': code. We have to, because there is no dedicated block available for accessing the setSleepIndicator function. But luckily, Espruino provides a general block that we can furnish with real JavaScript code.

    From Espruino we grab the block reading *// Enter JavaScript Code Here*and place it into the onInit function as first thing to execute. In the blocks 'input filed' we place type this code: setSleepIndicator(LED2);, which instructs Espruino to turn on the green LED before it goes to sleep, and turn it of when it is woken up by the interval timer to flip the LED's state and related state variable.

    After upload and blinking has started, we notice the the green LED is practically all the time of: Espruino is sleeping... The off is obviously so short that our eyes cannot notice.

    *Therefore, let's reverse the indicator to setBusyIndicator, because our eye can notice a very, very, very short flash*.

    E) Modify the program according to attachment 5 (2nd in this post): Simple Blink with Busy Indicator on Green LED

    Change the code in the code block to setBusyIndicator(LED2); (from setSleepIndicator(LED2);).

    After upload and blinking has started, we notice the the green LED is flashing very very briefly just before the red LED come on or goes out. The green flash is easier to spot just before the red LED goes out. The red LED on going on distracts the eye from easily noticing its flashing. But it IS there.

    *Now, we are ready take more control of the blinking process: let's just blink it 10 times and then turn LED2 on.

    F) Modify the program according to attachment 6 (3rd in this post): Blink red LED 10 times
    and then set Green LED on

    ...it does just then red LED flashes before turning green LED on.

    Earlier we were surprised how little Espruino was busy.

    Let's find out HOW busy Espruino really is... ...with the information provided in the next post.


    3 Attachments

    • D Simple Blink with Sleep Indicator on Green LED.png
    • E Simple Blink with Busy Indicator on Green LED.png
    • F Blink red LED 10 times and then set Green LED on.png
About

Avatar for allObjects @allObjects started