← Back to Getting Started with CircuitPython

Restart a Program with Ctrl+D

Step 7

Restarting a program

The code below runs once, prints a lucky number, and then stops. There's no loop keeping it alive. Click Connect, then Run on Device, and you'll see your lucky number in the console.

To run it again without re-uploading anything, click the Ctrl+D button to get a new lucky number. On CircuitPython, Ctrl+D triggers a "soft reboot." It re-runs code.py from the top, exactly as if you'd just saved a new version of the file. Click it a few times and watch a new random number appear each time.

code.py
Disconnected