I apologise in advance if this is a real “Noddy” question but is it possible In a micropython programme running on an RP2040 to use the RESET switch to halt and automatically restart the running programme?
In case anyone else should be interested in this topic, I have solved my own problem! If I save the programme as “main.py” and then reload this, it does what I want. Sorry if I have wasted anyones time.
In theory you should be able to wire an RP Pin to the Run Pin. Then in your code, set that RP Pin low and it will ground the Run Pin and cause a reboot / reset. That’s assuming that RP Pin doesn’t stay a low and goes high again on reboot.
That’s what the Captain Resseti button does, it grounds the Run Pin when / while pressed.
Thanks for the response, alphanumeric, but I seem to have dug myself a hole!! The little bit of code I am experimenting with has no end point; when I power the 2040, it runs automatically and does what I want but (I think because I renamed it main.py) I have no way of stopping it. I have tried Ctrl+C but to no avail. I have also tried to overwrite the programme in Thonny but again with no result. Ideally I would like to get back to a state where the Plasm 2040 board was as originally delivered, with the loaded programmes deleted but do not know how to achieve this. Any useful thoughts gratefully received !!!
If you go here,
Raspberry Pi Documentation - Raspberry Pi Pico
there is a link to a file that will erase everything in the Resetting Flash memory section.
What you end up with is a flash_nuke.uf2 file. Hold the Boot Select Button down and plug in the PICO’s USB cable. Then release the button and it should show up as RP2. Drop that flsah_nuke file on it / to it and you will reset it back to factory condition.
Thanks, alphanumeric. It worked a treat. I won’t make that mistake again !!!
Renaming the main.py file to anything but main will stop it from being autorun. Or just delete it. In thonny clicking stop should stop it, so you can do the above.
pretty sure I tried this but Thonny just reported the 2040 as busy. I have already implemented the clear Flash suggestion above so can’t easily go back but I would much rather spend my efforts in trying to pursue my original aim. I am trying to create a programme where I can use the three buttons (User, A and B) to control the mode of an LED strip (constant colour or rainbow), its colour and brightness and in the case of a rainbow, its cycle rate. Not easy with only three controls but it keeps thre grey matter exercised . Thanks for your help to date.