save() removes turns off all analogWrite()

Posted on
  • Hey everyone,
    I am doing a simple test with LEDs. I simply wrote

    analogWrite(B4, 0.1);
    

    and save()d the code onto my Pico. Whenever I disconnect and reconnect power, the light doesn't turn on! Same with all other pins, including software PWM.

    help!

  • Oh wait I changed the option from "save code to RAM" to "save directly to flash" and then back to RAM, and the problem was partially solved. My software PWM leds still turn off after a save().

  • "save code to RAM" to "save directly to flash" and then back to RAM

    You may find that you now have your 'old' code stored in flash memory as well as new code - you can remove that with reset(true).

    It might help to see http://www.espruino.com/Saving - when saving the contents of RAM (the default) Espruino saves the state of IO (digitalWrite/pinMode/etc) but not the state of PWM.

    Probably what you want is to call analogWrite(B4, 0.1); from a function called onInit, so that it is run automatically at boot.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

save() removes turns off all analogWrite()

Posted by Avatar for Marty_McFly @Marty_McFly

Actions