5.2. Editing Python programs

<p>With MicroPython installed on the robot, you can edit files directly on the board in any text editor. To get started, open <code>blink.py</code> on the MicroPython drive:</p> <table class="picture_with_caption center wide"><tr><td style="max-width: 600px"><a href="https://a.pololu-files.com/picture/0J12025.1200.png?54ebfa9f8edccca443512c40531d2085" class="noscript-fallback"><img alt="" class="wide zoomable" data-gallery-pictures="[{&quot;id&quot;:&quot;0J12025&quot;,&quot;caption&quot;:&quot;\u003cp\u003eThe blink.py demo program in a text editor.\u003c/p\u003e&quot;,&quot;url_tiny&quot;:&quot;https://a.pololu-files.com/picture/0J12025.98x98.jpg?54ebfa9f8edccca443512c40531d2085&quot;,&quot;url_medium&quot;:&quot;https://a.pololu-files.com/picture/0J12025.600x480.jpg?54ebfa9f8edccca443512c40531d2085&quot;,&quot;url_full&quot;:&quot;https://a.pololu-files.com/picture/0J12025.1200.png?54ebfa9f8edccca443512c40531d2085&quot;,&quot;longest_side&quot;:464}]" data-picture-id="0J12025" data-picture-longest_side="464" src="https://a.pololu-files.com/picture/0J12025.600.png?54ebfa9f8edccca443512c40531d2085" /></a></td><p></tr><tr><th style="max-width: 600px"><p>The blink.py demo program in a text editor.</p></th></tr></table></p> <p>This program turns the LED on for 100&nbsp;ms and off for 600&nbsp;ms, repeating forever. You can run this program from the menu of demo programs as described in <a href="/docs/0J86/4">Section 4</a>. Make a small change to it, such as replacing the 600 with 100, save the file, and select <code>blink.py</code> from the menu again (you might need to reset the robot to get there.) It will run your updated program with the new blinking pattern.</p> <p>Now, you can look around at the other files on the board, modify them, make new files, and run any of them from the menu. All of the original demo programs and other files are also available in <a href="https://github.com/pololu/pololu-3pi-2040-robot">our GitHub repository</a>.</p> <div class="note_warning"> <p><strong>Note:</strong> when editing files directly on the board, keep in mind that it is easy to lose them in various ways:</p> <ul> <li>Resetting or disconnecting the board while saving a file</li> <li>Editing files from within a MicroPython program and from your computer at the same time</li> <li>Loading a new firmware file that erases all data</li> <li>Software bugs or hardware failure</li> </ul> <p>To avoid losing work, we recommend saving backup copies periodically on your computer.</p> </div>

Related Products

3pi+ 2040 Robot - Standard Edition (30:1 MP Motors), Assembled
3pi+ 2040 Robot - Turtle Edition (75:1 LP Motors), Assembled
3pi+ 2040 Robot - Hyper Edition (15:1 HPCB Motors), Assembled
3pi+ 2040 Robot Kit with 30:1 MP Motors (Standard Edition Kit)
3pi+ 2040 Robot Kit with 75:1 LP Motors (Turtle Edition Kit)
3pi+ 2040 Robot Kit with 15:1 HPCB Motors (Hyper Edition Kit)
3pi+ 2040 Control Board
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors