Select Tools → Open system shell to install extra packages or learn handling Python on command line. Students can explore APIs with the help of code completion Variables are initially presented according to simplified model (name → value) but you can switch to more realistic model (name → address/id → value) Local variables are visually distinguished from globals Highlighting variable occurrences reminds you that the same name doesn't always mean the same variable and helps spotting typos. Unclosed quotes and parentheses are the most common beginners' syntax errors. Good understanding of how function calls work is especially important for understanding recursion Faithful representation of function calls.Stepping into a function call opens a new window with separate local variables table and code pointer.You can think of this light-blue box as a piece of paper where Python replaces subexpressions with their values, piece-by-piece The Python environment is available from the Python website you can download the latest version for your operating system from the downloads button near the. If you use small steps, then you can even see how Python evaluates your expressions. Steps follow program structure, not just code lines Press F6 for a big step and F7 for a small step. Just press Ctrl+F5 instead of F5 and you can run your programs step-by-step, no breakpoints needed. Once you're done with hello-worlds, select View → Variables and see how your programs and shell commands affect Python variables (You can also use a separate Python installation, if necessary.) The initial user interface is stripped of all features that may distract beginners Thonny comes with Python 3.10 built in, so just one simple installer is needed and you're ready to learn programming. Thonny will automatically download and install our latest firmware version from the Internet.Thonny is a Python IDE meant for learning programming. Select this option and then find the appropriate firmware in the list: Get the robot into bootloader mode as described in Section 5.1, and you will see an “Install MicroPython” option in the Thonny’s interpreter menu: You can also upgrade the MicroPython firmware with Thonny. Make sure you have anything you are working on backed up before you proceed. Note: Loading a firmware file will delete all programs and data stored on your robot. To start the demo program, press Ctrl+C (to stop the running program) then Ctrl+D (“soft” reboot). If you save your changes, you will be able to access them from the demo menu system later. Make some modifications and see that the blink pattern changes. Try that now and run the code again with the Run button or F5. To stop the program you can press Ctrl+C. Assuming you are still connected and see the MicroPython prompt, you can click the green Run button at the top or press F5 to run it immediately. Next, open blink.py in the Thonny editor. If basic commands work, you can try using the hardware on the 3pi+: You can program the board as a Pico or generic RP2040 board, but there will be more confusing options for file loading and saving. Note: If Thonny does not show the “Pololu 3pi+ 2040 Robot” option here, something is wrong with the plugin install. Next, you can try typing some commands in the Shell window: (If it doesn’t connect or isn’t showing any output, try clicking “Stop” to get connected.) Using Thonny to interact with the MicroPython interpreter Your currently-running program on the 3pi+ will stop, and the “Shell” window will show a MicroPython prompt (“REPL”). You should be able to select an option for the 3pi+ from the interpreter menu in the lower-right corner of Thonny: Next, connect your robot to your computer with a USB cable. Important: Restart Thonny after installing the plugin. Search for “ thonny-pololu”, select the corresponding plugin from PyPi, and click “Install”: Start the program, open the Tools menu, and click “Manage plug-ins…”: Install the latest version from the Thonny website. Installing Thonny and connecting to the 3pi+ After you download Thonny and install our plugin as described below, Thonny will recognize the 3pi+ and help you interact with the MicroPython interpreter running on its control board. Thonny is a Python editor for beginners that also includes advanced IDE features for editing and debugging code.
0 Comments
Leave a Reply. |