{"id":12609,"date":"2021-09-18T13:00:10","date_gmt":"2021-09-18T13:00:10","guid":{"rendered":"https:\/\/wolles-elektronikkiste.de\/micropython-switching-from-arduino"},"modified":"2022-01-20T20:04:14","modified_gmt":"2022-01-20T20:04:14","slug":"micropython-switching-from-arduino","status":"publish","type":"post","link":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino","title":{"rendered":"MicroPython &#8211; Switching from Arduino"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">About this post<\/h2>\n\n<p>This article is aimed at those who have experience in programming Arduino boards, but want to take a look beyond the horizon with MicroPython. For this purpose, I use the ESP32 as a microcontroller and uPyCraft as a MicroPython IDE.<\/p>\r\n<p>I will cover the following topics:<\/p>\r\n<ul>\r\n<li>Installing Python and uPyCraft<\/li>\r\n<li>Setting up uPyCraft for the ESP32<\/li>\r\n<li>Crash course in MicroPython<\/li>\r\n<li>Simple GPIO operations with MicroPython<\/li>\r\n<li>Appendix: Installing Thonny as an alternative to uPyCraft<\/li>\r\n<\/ul>\r\n<p>By the end of working through this post, you will be able to write simple MicroPython programs. In addition, you will be able to control the ESP32&#8217;s GPIOs with the counterparts of <code>digitalWrite()<\/code> and <code>digitalRead()<\/code>. In the next post I will show you how to use other functions of the ESP32 like PWM, A\/D converter, timer, etc. with MicroPython.<\/p>\r\n<p>It&#8217;s a lot of knowledge in a small space that I&#8217;m trying to impart here. In programming books, this would fill dozens of pages. So try things out and vary the examples, although many things may be boring at first. But only by practicing can you learn the language.<\/p>\r\n<p>Helpful, but not absolutely necessary, is previous experience with the ESP32. <a href=\"https:\/\/wolles-elektronikkiste.de\/en\/programming-the-esp32-with-arduino-code\" target=\"_blank\" rel=\"noopener\">Here<\/a> you can find more information on the ESP32.<\/p>\r\n\n<h2 class=\"wp-block-heading\">Python and MicroPython<\/h2>\n\n<p>Python is an object-oriented high-level language that is comparatively easy to learn. Python code is easy to read and very compact. The language is quite young &#8211; it was developed in the early 90s by Guido van Rossum. He is apparently a Monty Python fan because that&#8217;s where the name comes from. Among hobby electronics engineers, Python has spread mainly through its use on the Raspberry Pi.<\/p>\r\n<p>But Python also has disadvantages: the programs are interpreted and not compiled. This is very noticeable in the speed. Python is much slower than C++. In addition, it is more difficult to find bugs. Syntax errors are detected only when the interpreter encounters the corresponding line.&nbsp;<\/p>\r\n<p>You could say that in terms of Python, MicroPython is what the &#8220;Arduino language&#8221; is for C++, namely an adaptation for microcontrollers. Since the programs you create always require the MicroPython interpreter, this language is only suitable for microcontrollers with correspondingly large memory and sufficient computing power. MicroPython is available for the ESP32 and the ESP8266 among others.<\/p>\r\n<p>On <a href=\"https:\/\/docs.micropython.org\/en\/latest\/index.html\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.micropython.org\/en\/latest\/index.html<\/a> you will find the excellently structured documentation for MicroPython.<\/p>\r\n\n<h2 class=\"wp-block-heading\">Preparation: Installing Python<\/h2>\n\n<p>You have to install Python first, because MicroPython is based on it.<\/p>\r\n<ol>\r\n<li>On <a href=\"https:\/\/www.python.org\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.python.org\/<\/a> you will find the download link for the latest version.<\/li>\r\n<li>In the Files section (scroll down a bit on the page), you select the correct installation file. For Windows, the best option is &#8220;Windows installer (64-bit)&#8221;.<\/li>\r\n<li>Run the installation file, and choose &#8220;Add Python <em>version<\/em> to PATH&#8221;.<\/li>\r\n<\/ol>\r\n\n<h2 class=\"wp-block-heading\">Installing uPyCraft and setting up the ESP32<\/h2>\n\n<h3 class=\"wp-block-heading\">Installation<\/h3>\n\n<p>If you are using Windows, you can download uPyCraft <a href=\"https:\/\/github.com\/DFRobot\/uPyCraft\/raw\/master\/uPyCraft.exe\" target=\"_blank\" rel=\"noopener\">here<\/a>. There is no installation file, but you get the executable program directly as an &#8220;.exe&#8221; file. &nbsp; Copy it to the folder you want to work from.<\/p>\r\n<p>When you start uPyCraft for the first time, you will probably be prompted to install SourceCodePro. After that, you will find a file called SourceCodePro.ttf on your computer. This contains the required character sets. To prevent you from being asked for it again every time you start the program, right-click on the file and select &#8220;Install for all users&#8221; (or similar &#8211; my Windows is in German).<\/p>\r\n<p>You will also be asked if you want to install a newer version of uPyCraft. Click OK. Now you will find another file called uPyCraft_Vx.y.exe. You can now delete the original uPyCraft.exe file.<\/p>\r\n<p>In order for MicroPython to run on the ESP32, you now have to download the firmware for the ESP32. To do this, go to <a href=\"https:\/\/micropython.org\/download\/esp32\/\" target=\"_blank\" rel=\"noopener\">https:\/\/micropython.org\/download\/esp32\/<\/a> and choose the latest, stable &#8220;GENERIC&#8221; version:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft_select_firmware.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"232\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft_select_firmware-1024x232.png\" alt=\"MicroPython Firmware for the ESP32 (watch out for newer versions)\" class=\"wp-image-12261\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft_select_firmware-1024x232.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft_select_firmware-300x68.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft_select_firmware-768x174.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft_select_firmware.png 1124w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>MicroPython Firmware for the ESP32 (watch out for newer versions)<\/figcaption><\/figure>\n<p>It is best to store the firmware file in your uPyCraft folder.<\/p>\r\n\n<h3 class=\"wp-block-heading\">The uPyCraft user interface<\/h3>\n\n<p>The user interface of uPyCraft consists of five sections:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft__surface.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"702\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft__surface-1024x702.png\" alt=\"uPyCraft for MicroPython - User Interface \" class=\"wp-image-12390\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft__surface-1024x702.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft__surface-300x206.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft__surface-768x527.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft__surface.png 1213w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>uPyCraft User Interface <\/figcaption><\/figure>\n<ol>\r\n<li>File management<\/li>\r\n<li>Program Editor<\/li>\r\n<li>Shell (Input \/ Output)<\/li>\r\n<li>Toolbar<\/li>\r\n<li>Menu bar<\/li>\r\n<\/ol>\r\n<p>Explanations will follow &#8211; I just want to make sure at this point that you know what I&#8217;m talking about when I refer to these sections.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Setting up the ESP32<\/h3>\n\n<p>Connect the ESP32 to your computer. Go to the menu bar \u2192 Tools \u2192 Serial, select the port to which your ESP32 is connected. Click on it. If the port does not appear, you may be missing a driver for the USB-to-UART adapter on the ESP32. In this case you can find the driver <a href=\"https:\/\/www.silabs.com\/developers\/usb-to-uart-bridge-vcp-drivers\" target=\"_blank\" rel=\"noopener\">here<\/a>.&nbsp;<\/p>\r\n\n<h4 class=\"wp-block-heading\">Burning the Firmware<\/h4>\n\n<p>Now you have to burn the firmware on your ESP32. To do this, go to Tools \u2192 BurnFirmware. Select the firmware file you downloaded earlier. The correct settings look like this (your port must of course be adjusted):<\/p>\r\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/upycraft_burn_fw.png\"><img loading=\"lazy\" decoding=\"async\" width=\"452\" height=\"290\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/upycraft_burn_fw.png\" alt=\"Burning the MicroPython firmware\" class=\"wp-image-12268\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/upycraft_burn_fw.png 452w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/upycraft_burn_fw-300x192.png 300w\" sizes=\"auto, (max-width: 452px) 100vw, 452px\" \/><\/a><figcaption>Burning the MicroPython firmware for the ESP32<\/figcaption><\/figure><\/div>\n\n<p>If the burning process does not work, you may have to press the boot button first. This depends on your board.<\/p>\r\n<p>If everything went well, the prompt &#8220;&gt;&gt;&gt;&#8221; appears. You may need to reset the ESP32 or disconnect it from power briefly. When you plug it back in, you have to select the serial port again. uPyCraft is not particularly smart in this regard.<\/p>\r\n<p>With that, you have made it and can finally get started.<\/p>\r\n\n<h2 class=\"wp-block-heading\">Getting Started<\/h2>\n\n<p>Python allows you to enter and test code directly in the shell (input\/output window). This is called REPL for &#8220;Read-Evaluate-Print Loop&#8221;. REPL is a great thing that wouldn&#8217;t be possible with a compiler-based language in this form.<\/p>\r\n<p>Try it out by typing <code>a = 42<\/code> (or your favorite number) first and confirming with Enter. The next statement is <code>print(\"a =\", a)<\/code>. As output you get <code>a = 42<\/code>. Use <code>type(a)<\/code> to query the variable type of <code>a<\/code>. Now, enter <code>a *= 1.0<\/code>, then <code>a<\/code> and finally again <code>type(a)<\/code>:<\/p>\r\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/upycraft_first_test.png\" alt=\"Get started with MicroPython in the uPyCraft Shell.\" class=\"wp-image-12377\" width=\"840\" height=\"192\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/upycraft_first_test.png 871w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/upycraft_first_test-300x69.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/upycraft_first_test-768x176.png 768w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><figcaption>First Steps with MicroPython<\/figcaption><\/figure>\n<p>You&#8217;ve already learned a lot about Python:<\/p>\r\n<ul>\r\n<li>You don&#8217;t have to declare any variable types. Python interprets the type based on the format of the input:\r\n<ul>\r\n<li><code>a = 42.0<\/code> would be a float.<\/li>\r\n<li>With <code>a = \"42\"<\/code> a would be a string. <code>a = '42'<\/code> is equivalent.<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>Statements are not completed by a semicolon, but by a line break.<\/li>\r\n<li>Variable types are defined as a class.<\/li>\r\n<li><code>print()<\/code> creates a line break in the output.<\/li>\r\n<li>In the shell it is sufficient to enter the variable name + Enter to get the value of the variable.<\/li>\r\n<li>Variable types are converted implicitly to a greater extent than in C++. <code>a *= 1.0<\/code> would not have triggered a conversion in C++.\r\n<ul>\r\n<li>Explicit conversions, e.g. <code>float(variable)<\/code>, <code>int(variable)<\/code> or<code>str(variable)<\/code> are also possible.<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>You can combine several outputs into one <code>print()<\/code> statement, each separated by a comma.\r\n<ul>\r\n<li>Python automatically inserts spaces between the outputs.<\/li>\r\n<\/ul>\r\n<\/li>\r\n<\/ul>\r\n<p>If you want to prevent the line break, enter <code>end = \"\"<\/code> as last argument, for example <code>print(\"a =\", a, end=\"\")<\/code>.<\/p>\r\n<p>Conveniently, you can use the &#8220;up\/down&#8221; arrow keys to scroll to your previous entries.<\/p>\r\n\n<h3 class=\"wp-block-heading\">The first program<\/h3>\n\n<p>Typing code directly into the shell is nice for trying things out, but usually you will write your programs as files. We come to that now. In addition, you certainly want to learn how to control the GPIOs with MicroPython.<\/p>\r\n<p>Connect an LED with resistor (remember the 3.3 volts) to a GPIO of the ESP32. I chose GPIO18. Then go to File \u2192 New in the menu bar. Alternatively, click on the top icon in the toolbar. The title &#8220;untitled&#8221; and the line numbering appear in the program editor. Enter the following program &#8220;blink.py&#8221;:<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-group=\"blink.py\" data-enlighter-title=\"blink.py\">from machine import Pin\r\nfrom time import sleep\r\nled = Pin(18, Pin.OUT)\r\nwhile True:\r\n    led.value(1) \r\n    sleep(1)\r\n    led.value(0)\r\n    sleep(1)<\/pre>\r\n<p>Save the program via the menu bar (File \u2192 Save) or via the floppy disk icon. In the pop-up window you enter a file name (Input File). Then you will be asked once where the workspace of uPyCraft should be created. In the selected directory (preferably your uPyCraft folder) uPyCraft creates the directory &#8220;workSpace&#8221; and the subdirectory &#8220;user_lib&#8221;. Your Python programs are stored in the workspace.<\/p>\r\n\n<p>Now go to Tools \u2192 DownloadAndRun or press F5 or you click on the triangle in the toolbar. The program is then uploaded to the ESP32 and executed. The LED should now flash every second.<\/p>\r\n\n<h4 class=\"wp-block-heading\">File Handling<\/h4>\n\n<p>Now click on Files \u2192 Reflush Directory. This will update the file directory. Then click on the triangles next to &#8220;device&#8221; and next to &#8220;workSpace&#8221;. As you will see, the file blink.py is now located both in the workspace and on the ESP32 (= device). Both files can be edited independently. Before you can open the version on the ESP32, however, you have to exit the running program with &#8220;Stop&#8221; (via toolbar or menu bar).<\/p>\r\n<p>You can tell which version you have opened by the icon next to the file name in the program editor. I recommend to work with the version from the workspace.<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft_device_vs_workspace.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1002\" height=\"433\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft_device_vs_workspace.png\" alt=\"blink.py in the workspace and on the ESP32\" class=\"wp-image-12277\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft_device_vs_workspace.png 1002w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft_device_vs_workspace-300x130.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/uPyCraft_device_vs_workspace-768x332.png 768w\" sizes=\"auto, (max-width: 1002px) 100vw, 1002px\" \/><\/a><figcaption>blink.py in the workspace and on the ESP32<\/figcaption><\/figure>\n<p>If you create more programs and upload them to the ESP32 (download in the uPyCraft language), they will <em>additionally<\/em> be stored on the ESP32. If you want to delete a file on the ESP32, right-click on the file in the device directory and choose &#8220;delete&#8221;.<\/p>\r\n\n<h4 class=\"wp-block-heading\">Automatic program start<\/h4>\n\n<p>When you leave uPyCraft, the execution of blink.py also stops. To get blink.py running again, you have to restart uPyCraft, choose the serial port, call blink.py and start DownloadAndRun. You also cannot start blink.py automatically by resetting the ESP32 or briefly disconnecting it from the power supply. This makes sense, since you can have several programs on the ESP32.<\/p>\r\n<p>For a Python program to start automatically on the ESP32, it must be named &#8220;main.py&#8221;. Unfortunately, there is a problem with this. Because when main.py is running, you cannot connect via the serial port. And consequently you cannot stop main.py. I couldn&#8217;t find any other option with uPyCraft than to re-burn the firmware. Therefore, wait until you have finished your project before renaming it to main.py. Alternatively, you can use Thonny (see appendix). With this program, you can stop the running main.py with control \/ c. <\/p>\r\n\n<h4 class=\"wp-block-heading\">Explanations about blink.py<\/h4>\n\n<p>Let&#8217;s go back to the code. With <code>from module import class\/method<\/code> classes or methods are imported from modules that are not part of the basic configuration. This is similar to the <code>#include<\/code> preprocessor directive in C++. In blink.py, the class &#8220;Pin&#8221; is imported from the module &#8220;machine&#8221; and the function &#8220;sleep&#8221; is imported from the module &#8220;time&#8221;. An overview of the different ESP32-specific modules, classes and their methods can be found in the <a href=\"https:\/\/docs.micropython.org\/en\/latest\/esp32\/quickref.html\" target=\"_blank\" rel=\"noopener\">Quick Reference Guide<\/a>.<\/p>\r\n<p>The statement<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-linenumbers=\"false\">led = Pin(18, Pin.OUT)<\/code><\/p>\r\n<p>corresponds to the Arduino code:<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-linenumbers=\"false\">int led = 18;\r\n<\/code><\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-linenumbers=\"false\">pinMode(led, OUTPUT);<\/code><\/p>\r\n<p>However, with the difference that &#8220;led&#8221; in MicroPython is an object of the class Pin. Accordingly, the pin is switched to HIGH or LOW state using a method of the pin class:<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">led.value(1)<\/code> or <code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">led.value(0)<\/code><\/p>\r\n<p>Alternatively, you can also use:<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">led.on()<\/code> or <code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">led.off()<\/code><\/p>\r\n<p>You can pass more arguments to <code>Pin()<\/code>, e.g. the pin state:<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">led = Pin(18, PIN.OUT, value=1)<\/code> or in short: <code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">led = Pin(18, PIN.OUT, 1)<\/code><\/p>\r\n<p>If you want to set a pin to input and need a pull-up or pull-down resistor (e.g. to read a key), it looks like this:<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">buttonPin = Pin(18, Pin.IN, PIN.PULL_DOWN)&nbsp;&nbsp; # or: PULL_UP<\/code><\/p>\r\n<p>Here you also learned that you mark comments with a &#8220;#&#8221; instead of &#8220;\/\/&#8221;.<\/p>\r\n<p><code>sleep()<\/code> corresponds to <code>delay()<\/code>, but you pass seconds to function. With <code>sleep_ms()<\/code> you pass milliseconds and <code>sleep_us()<\/code> corresponds to <code>delayMicroseconds()<\/code>.<\/p>\r\n<p><code>loop()<\/code> is replaced by <code>while True:<\/code> in MicroPython. Everything before and in <code>setup()<\/code> is placed before the while loop in MicroPython.<\/p>\r\n<p>The condition for the while loop is not enclosed in parentheses, nor are the statements within the loop. The indentation alone indicates what belongs to the loop. With Arduino \/ C++ the indentation is only for readability, but with MicroPython it has a real meaning.<\/p>\r\n<p>The last point I want to make is that as an alternative to <code>from ... import ...<\/code>, simply <code>import ...<\/code> is also allowed. However, you have to prefix the classes and methods with the module names:<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-group=\"blink_mod.py\" data-enlighter-title=\"blink_mod.py\">import machine\r\nimport time\r\nled = machine.Pin(18, machine.Pin.OUT)\r\nwhile True:\r\n    led.on()\r\n    time.sleep(1)\r\n    led.off()\r\n    time.sleep(1)<\/pre>\r\n\n<h2 class=\"wp-block-heading\">Other general MicroPython elements<\/h2>\n\n<h3 class=\"wp-block-heading\">Operators<\/h3>\n\n<p>The arithmetic operators <code>+<\/code>, <code>-<\/code>, <code>*<\/code>, <code>\/<\/code> are identical to those in Arduino \/ C++ and the same applies to the modulo <code>%<\/code>. Exponential functions can be realized with <code>**<\/code>, e.g. <code>2**4<\/code> for &#8220;2 to the 4&#8221;. The operator for integer division is <code>\/\/<\/code>.<\/p>\r\n<p>As logical operators <code>and<\/code>, <code>or<\/code> and <code>not<\/code> are available. Just written out, so not like the C++ operators <code>||,<\/code> <code>&amp;&amp;<\/code> and <code>!<\/code>.<\/p>\r\n<p>The bit and shift operators <code>&amp;<\/code>,  <code>|<\/code>,  <code>^<\/code>,  <code>~<\/code>,  <code>&lt;&lt;<\/code>,  <code>&gt;&gt;<\/code> are again identical to the Arduino \/ C++ spelling. The same applies to the comparison operators: <code>&lt;<\/code>,  <code>&gt;<\/code>,  <code>&lt;=<\/code>,  <code>&gt;=<\/code>,  <code>==<\/code>,  <code>!=<\/code>.<\/p>\r\n<p>You find an overview of mathematical functions such as sine, root, etc. <a href=\"https:\/\/docs.micropython.org\/en\/latest\/library\/math.html\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Number systems<\/h3>\n\n<p>As in C++, binary, octal, and hexadecimal numbers are represented as <code>0b...<\/code>, <code>0o...<\/code> and <code>0x...<\/code>. If you want to output a number in a certain format, then use <code>bin()<\/code>, <code>oct()<\/code> or <code>hex()<\/code>. For example: <code>print(bin(a))<\/code>.<\/p>\r\n<p>In addition, MicroPython can also handle complex numbers.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Lists and arrays<\/h3>\n\n<p>MicroPython offers a wide range of different data collections. These include lists, arrays, bytearrays, tuples, sets, dictionaries, and others. They differ, among other things, in:<\/p>\r\n<ul>\r\n<li>the types of data they can handle,<\/li>\r\n<li>whether they are mutable or immutable<\/li>\r\n<li>and whether the individual elements have a fixed order, i.e. have an index. <\/li>\r\n<\/ul>\r\n<p>Lists are very flexible and are used very often. They are framed by square brackets and their elements are separated by commas. Here is an example:<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">l = [42, True, \"abc\", 66.6]<\/code><\/p>\r\n<p>Lists are mutable, they can be expanded and sorted. You can access individual elements. Lists can be concatenated (appended to each other). Lists are also allowed as elements of lists. The following inputs and outputs are &#8211; I think &#8211; self-explanatory.<\/p>\r\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/list_options.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/list_options.png\" alt=\"Operations with lists in MicroPython\" class=\"wp-image-12316\" width=\"840\" height=\"405\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/list_options.png 999w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/list_options-300x145.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/list_options-768x371.png 768w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/a><figcaption>Operations with lists in MicroPython<\/figcaption><\/figure>\n<p>I have forgotten an important function for lists: <code>len(l)<\/code> returns the number of items in the list l.<\/p>\r\n<p>Arrays are basically lists that allow only one data type. Otherwise, you can apply the same methods to them. Arrays work more efficiently than lists, which can become relevant for large amounts of data. Here&#8217;s an example of how to create an array:<\/p>\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">import array as arr\r\na = arr.array(\"i\", [3,7,9,25])<\/pre>\r\n<p>The &#8220;i&#8221; stands for Integer. Here, exceptionally, a data type must be specified in MicroPython. For an array of floats, you must specify &#8220;f&#8221;. It&#8217;s best to play around with lists and arrays a bit to get familiar with them.<\/p>\r\n\n<h4 class=\"wp-block-heading\">Mutable and immutable objects<\/h4>\n\n<p>The following lines are not surprising:<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var.png\"><img loading=\"lazy\" decoding=\"async\" width=\"939\" height=\"92\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var.png\" alt=\"\" class=\"wp-image-12332\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var.png 939w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var-300x29.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var-768x75.png 768w\" sizes=\"auto, (max-width: 939px) 100vw, 939px\" \/><\/a><\/figure>\n<p>However, this could be the case here:<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"899\" height=\"93\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var2.png\" alt=\"\" class=\"wp-image-12334\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var2.png 899w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var2-300x31.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var2-768x79.png 768w\" sizes=\"auto, (max-width: 899px) 100vw, 899px\" \/><\/a><\/figure>\n<p>In (Micro)Python, everything is an object. And variables are names that reference these objects. We can also say that the names are bound to the objects. MicroPython distinguishes between mutable and immutable objects. For example, a &#8220;1&#8221; is an object of the class &#8220;int&#8221; and is <em>immutable<\/em>. Sounds weird, but it is. Lists and arrays, on the other hand, are mutable.<\/p>\r\n<p>In the first example, a and b first refer to the same object, namely &#8220;1&#8221;. With <code>b = 2<\/code> b refers to a new object, namely &#8220;2&#8221;. &#8220;a&#8221; remains unaffected. In the second example, however, &nbsp; <code>b[0] = 2<\/code> does not change the binding to the object (namely the list), but changes the object because it is mutable.<\/p>\r\n<p>The next example does change the binding:<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"902\" height=\"88\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var3.png\" alt=\"\" class=\"wp-image-12336\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var3.png 902w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var3-300x29.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/var3-768x75.png 768w\" sizes=\"auto, (max-width: 902px) 100vw, 902px\" \/><\/a><\/figure>\n<p>Each object in MicroPython has its individual ID, which you can query with <code>id(object)<\/code>. Try this:<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">a = 1<\/code>,<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">id(a)<\/code>,<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">a += 1<\/code> and finally this:<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">id(a)<\/code><\/p>\r\n<p>As you can see, the ID of a changes. If you are still motivated, enter <code>id(2)<\/code>. Consequently, <code>id(a)<\/code> is equal to <code>id(2)<\/code>.&nbsp;<\/p>\r\n<p>If you internalize this, you will be able to better understand various things in MicroPython. Among other things, the topic becomes important when you pass lists, arrays or other mutable objects to functions and modify them there. Because only the references are passed, and the functions work with the originals. It&#8217;s like passing references in C++.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Tuples and bytearrays<\/h3>\n\n<p>I had already mentioned tuples and byte arrays above. I need to go into more detail about these data types, as you are very likely to encounter them. It&#8217;s a bit confusing at first to distinguish lists, arrays, bytearrays and tuples. And it&#8217;s pretty boring at first. The good news is that the methods you can apply to them are repetitive.<\/p>\r\n\n<h4 class=\"wp-block-heading\">Tuple<\/h4>\n\n<p>Basically, tuples are just immutable lists. You can add data of any type to tuples. Unlike the lists, tuples are defined in parentheses. However, you can also omit the brackets. Personally, I find it easier to read with parentheses.<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/09\/tuple_test.png\"><img loading=\"lazy\" decoding=\"async\" width=\"838\" height=\"244\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/09\/tuple_test.png\" alt=\"\" class=\"wp-image-12510\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/09\/tuple_test.png 838w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/09\/tuple_test-300x87.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/09\/tuple_test-768x224.png 768w\" sizes=\"auto, (max-width: 838px) 100vw, 838px\" \/><\/a><figcaption>Tuple &#8211; Operations<\/figcaption><\/figure>\n<p>As you can see, tuple_2[4] = 43 does not work. Tuples are not mutable.<\/p>\r\n\n<h4 class=\"wp-block-heading\">Bytearrays<\/h4>\n\n<p>Not surprisingly, bytearrays are arrays that contain only bytes. Like the other arrays, they are mutable. The best way to define bytearrays is to pass a list to the function <code>bytearray()<\/code>. Here are a few examples:<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"834\" height=\"193\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/09\/bytearray.png\" alt=\"\" class=\"wp-image-12512\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/09\/bytearray.png 834w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/09\/bytearray-300x69.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/09\/bytearray-768x178.png 768w\" sizes=\"auto, (max-width: 834px) 100vw, 834px\" \/><figcaption>Bytearray Operations<\/figcaption><\/figure>\n<p>The somewhat cryptic output is noticeable when you output the byte array as a whole. If the value of an element corresponds to a printable ASCII character, the character is printed. If this is not the case, the element is output in the format \\xyy, where yy is the value in hexadecimal notation.&nbsp;<\/p>\r\n\n<p>I don&#8217;t even dare to say it: There&#8217;s more!<\/p>\r\n<ul>\r\n<li><strong>Bytestrings:<\/strong>are <em>immutable<\/em> bytearrays which are defined with <code>bytes()<\/code> instead of <code>bytearray()<\/code>. Otherwise, everything is the same.<\/li>\r\n<li><strong>Dictionaries<\/strong>: resemble enum expressions. For those who still don&#8217;t have enough: look <a href=\"https:\/\/techtutorialsx.com\/2017\/08\/31\/esp32-esp8266-micropython-working-with-dictionaries\/\" target=\"_blank\" rel=\"noopener\">here.<\/a><\/li>\r\n<li><strong>Sets<\/strong>: are unordered, mutable collections that do not allow duplicate elements. You will rarely need sets.<\/li>\r\n<\/ul>\r\n\n<h3 class=\"wp-block-heading\">Other loops and conditions<\/h3>\n\n<h4 class=\"wp-block-heading\">if &#8211; else &#8211; elif statements<\/h4>\n\n<p>There is little to say about <code>if<\/code> and <code>else<\/code>. <code>else if<\/code> is called <code>elif<\/code> in MicroPython.  Here&#8217;s an example, which admittedly is pretty pointless in itself:<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-group=\"if_else_elif.py\" data-enlighter-title=\"if_else_elif.py\">from time import sleep\r\nfrom random import randint   \r\nwhile True:\r\n    n = randint(-10, 30)   # random integer between -10 and +30\r\n    print(\"Random number =\", n)\r\n    if n &gt; 0:\r\n        if n &gt; 20:\r\n            print(\"Number is bigger than 20\")\r\n        elif n &gt; 10:\r\n            print(\"Number is bigger than 10\")\r\n        else:\r\n            print(\"Number is bigger than 0\")\r\n    elif n &lt;= 0:\r\n        print(\"Number &lt;= 0\")\r\n    print(\"...........\")\r\n    sleep(1.5)<\/pre>\r\n\n<p>In addition, you learn from this example:<\/p>\r\n<ul>\r\n<li>Random numbers in a range from x to y (including the limits) are generated with <code>randint(x,y)<\/code>.<\/li>\r\n<li>The function <code>randint()<\/code> must be imported.<\/li>\r\n<li><code>sleep()<\/code> also works with floats.<\/li>\r\n<\/ul>\r\n\n<h4 class=\"wp-block-heading\">For &#8211; statements<\/h4>\n\n<p>Enter the following in the shell:<\/p>\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">for i in range(1,4):\r\n    print(i)\r\n<\/pre>\r\n<p>You can see that MicroPython is smart and expects more input after the colon. You will receive:<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/simple_for.png\"><img loading=\"lazy\" decoding=\"async\" width=\"972\" height=\"177\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/simple_for.png\" alt=\"&quot;for&quot;-loop in MicroPython\" class=\"wp-image-12321\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/simple_for.png 972w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/simple_for-300x55.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/simple_for-768x140.png 768w\" sizes=\"auto, (max-width: 972px) 100vw, 972px\" \/><\/a><figcaption>&#8220;for&#8221;-loop in MicroPython<\/figcaption><\/figure>\n<p><code>for i in range(1,4)<\/code> is therefore equivalent to the Arduino\/C++ expression: <code>for(int i=1; i&lt;4; i++)<\/code>. You can pass a third parameter to <code>range()<\/code> and change the increment this way. Try <code>range(1,10,2)<\/code> and <code>range(4,1,-1)<\/code> see what happens.<\/p>\r\n<p>Or you only pass one parameter, namely the upper limit. <code>range(x)<\/code> corresponds to <code>range(0,x)<\/code>.<\/p>\r\n<p>These statements also work:<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/further_range_options.png\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"339\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/further_range_options.png\" alt=\"\" class=\"wp-image-12325\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/further_range_options.png 960w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/further_range_options-300x106.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/further_range_options-768x271.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><figcaption>More examples of for-statements<\/figcaption><\/figure>\n<p>You can see that MicroPython allows you to write fairly compact code.<\/p>\r\n\n<h2 class=\"wp-block-heading\">Functions<\/h2>\n\n<p>The use of functions is also not significantly different from C++. Here is a small example:<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-group=\"simple_function.py\" data-enlighter-title=\"simple_fuction.py\">def double_it(i):\r\n    result = i * 2\r\n    return result\r\n  \r\nn = 5\r\nprint(\"5 * 2 =\", double_it(n))\r\nn = 5.0\r\nprint(\"5.0 * 2 =\", double_it(n))\r\nn = \"Hello\"\r\nprint(\"Hello * 2 =\", double_it(n))<\/pre>\r\n\n<p>The output is:<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/output_simple_function.png\"><img loading=\"lazy\" decoding=\"async\" width=\"927\" height=\"69\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/output_simple_function.png\" alt=\"\" class=\"wp-image-12327\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/output_simple_function.png 927w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/output_simple_function-300x22.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/output_simple_function-768x57.png 768w\" sizes=\"auto, (max-width: 927px) 100vw, 927px\" \/><\/a><\/figure>\n<p>What you learn from it:<\/p>\r\n<ul>\r\n<li>Functions are defined with <code>def function_name(parameter):<\/code>.\r\n<ul>\r\n<li>Multiple parameters can be passed separated by commas.<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>You do not need to specify any data types for the parameters and return values. This makes the functions very flexible, as you can see.<\/li>\r\n<\/ul>\r\n\n<h2 class=\"wp-block-heading\">Formatted output<\/h2>\n\n<p>In Python or MicroPython, there are many ways to output numbers and strings formatted. First, here is a non-formatted example:&nbsp;<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/format_unformatiert.png\"><img loading=\"lazy\" decoding=\"async\" width=\"855\" height=\"63\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/format_unformatiert.png\" alt=\"\" class=\"wp-image-12353\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/format_unformatiert.png 855w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/format_unformatiert-300x22.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/format_unformatiert-768x57.png 768w\" sizes=\"auto, (max-width: 855px) 100vw, 855px\" \/><\/a><\/figure>\n<p>And here are some formatted examples:<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/format_formatiert.png\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"112\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/format_formatiert.png\" alt=\"\" class=\"wp-image-12355\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/format_formatiert.png 865w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/format_formatiert-300x39.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/format_formatiert-768x99.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/format_formatiert-860x112.png 860w\" sizes=\"auto, (max-width: 865px) 100vw, 865px\" \/><\/a><\/figure>\n<p>This is less complicated than it looks at first glance. You replace the numbers you want to format with a formatting statement in curly braces. The data to be formatted is attached with <code>.format(...)<\/code> at the end. The scheme for the formatted output is:<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">print(\" ..... {Format_0} ...... {Format_1}.....\".format(Argument_0, Argument_1,...))<\/code><\/p>\r\n<p>The format statement Format_x is structured as follows:<\/p>\r\n<p>{N:FTotallength.Decimal placesT} with:<\/p>\r\n<ul>\r\n<li>N = number of the format statement (optional)<\/li>\r\n<li>F = other formatting statements:\r\n<ul>\r\n<li>&lt;, &gt;, ^ for left-aligned, right-aligned, centered<\/li>\r\n<li>0 for preceding zeros<\/li>\r\n<li>+ for signs<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>T = number type:\r\n<ul>\r\n<li>d = decimal (Integer)<\/li>\r\n<li>f = float<\/li>\r\n<li>b = binary<\/li>\r\n<li>x = hexadecimal<\/li>\r\n<\/ul>\r\n<\/li>\r\n<li>Without T = string (only with N, F and Totallength)<\/li>\r\n<\/ul>\r\n\n<p>This spelling is the modern variant in (micro)Python. There is also an obsolete notation with modulo (%), which I will not go into here.<\/p>\r\n<p>More about formatting can be found <a href=\"https:\/\/www.python-course.eu\/python3_formatted_output.php\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\r\n\n<h2 class=\"wp-block-heading\">Precision \/ Limitations for float and integer<\/h2>\n\n<p>I&#8217;ll come back to the integer and float types. Look at the following inputs\/outputs:<\/p>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/float_int_precision.png\"><img loading=\"lazy\" decoding=\"async\" width=\"860\" height=\"220\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/float_int_precision.png\" alt=\"\" class=\"wp-image-12363\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/float_int_precision.png 860w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/float_int_precision-300x77.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/float_int_precision-768x196.png 768w\" sizes=\"auto, (max-width: 860px) 100vw, 860px\" \/><\/a><\/figure>\n<p>MicroPython uses only &#8220;int&#8221; for integers and only &#8220;float&#8221; for floating-point numbers. There is no such thing as &#8220;unsigned int&#8221;, &#8220;long&#8221; or &#8220;double&#8221;. Nevertheless, MicroPython can handle gigantic integers, as you can see above. But as generous as MicroPython is with integers, it is stingy with floats. After 7 digits is &nbsp; over. 10\/3 is certainly not 3.3333332539. &nbsp;<\/p>\r\n\n<h2 class=\"wp-block-heading\">Application \/ deepening of knowledge<\/h2>\n\n<p>That was a lot of theory. But you already know a lot about MicroPython. For relaxation, I have now a bit of practice for you. With the following circuit, a chaser light consisting of 5 LEDs is realized.<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/led_chaser.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"424\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/led_chaser-1024x424.png\" alt=\"Circuit for a chaser light\" class=\"wp-image-12341\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/led_chaser-1024x424.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/led_chaser-300x124.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/led_chaser-768x318.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/led_chaser-1536x637.png 1536w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/led_chaser-1320x547.png 1320w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/led_chaser.png 1609w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Circuit for a chaser light<\/figcaption><\/figure>\n<p>As long as one of the two buttons is pressed, the running light is active. Depending on which button is pressed, the light runs in one direction or the other.<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-group=\"chaser_light.py\" data-enlighter-title=\"chaser_light.py\">from machine import Pin\r\nfrom time import sleep \r\n\r\nled = [19, 18, 5, 17, 16] \r\nbtn1 = Pin(22, Pin.IN, Pin.PULL_DOWN)\r\nbtn2 = Pin(23, Pin.IN, Pin.PULL_DOWN)\r\n\r\nfor i in range(len(led)):\r\n    led[i] = Pin(led[i], Pin.OUT)\r\n\r\ndef chaser(reverse = True):\r\n    if reverse:\r\n        for i in range(4,-1,-1):\r\n            led[i].value(1)\r\n            sleep(0.15)\r\n            led[i].value(0)\r\n    else:\r\n        for i in range(0,5):\r\n            led[i].value(1)\r\n            sleep(0.15)\r\n            led[i].value(0)\r\n  \r\nwhile True:\r\n    if btn1.value():\r\n        chaser()\r\n    elif btn2.value():\r\n        chaser(False)<\/pre>\r\n\n<p>The following is new:<\/p>\r\n<ul>\r\n<li><code>btn1.value()<\/code> returns the state (HIGH\/LOW) of btn1.<\/li>\r\n<li>With <code>def chaser(reverse = True)<\/code> &nbsp; reverse is &#8220;True&#8221; if &#8220;chaser&#8221; is called without parameters.<\/li>\r\n<\/ul>\r\n<p>I would also like to turn your attention to the following line:<\/p>\r\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">led[i] = Pin(led[i], Pin.OUT)<\/code><\/p>\r\n<p>&#8220;led&#8221; is a list whose elements are initially integers. The above statement replaces the ith element with an object of the class Pin. This only works because lists are allowed to contain items of different data types. You couldn&#8217;t do something like that with an array.<\/p>\r\n\n<h2 class=\"wp-block-heading\">Outlook<\/h2>\n\n<p>You have learned the basics of MicroPython in this post, and you know how to upload programs to the ESP32. In addition, you have gained first experience with the control of the GPIOs. In the next post, I will build on this and show how you can use other functions of the ESP32 with MicroPython. This includes PWM, the A\/D converters, timers, interrupts, touch pins and much more.<\/p>\r\n\n<h2 class=\"wp-block-heading\">Appendix: Thonny &#8211; the more comfortable IDE<\/h2>\n\n<p>uPyCraft meets the basic requirements for a MicroPython IDE. However, the program is not particularly convenient. You have only a few setting options, and even simple editing tools for commenting or indenting are missing. However, it is slim does require little space.<\/p>\r\n<p>Very common is the alternative Thonny:<\/p>\r\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Thonny_surface.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"622\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Thonny_surface-1024x622.png\" alt=\"Thonny User Interface\" class=\"wp-image-12347\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Thonny_surface-1024x622.png 1024w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Thonny_surface-300x182.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Thonny_surface-768x466.png 768w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Thonny_surface.png 1080w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Thonny User Interface<\/figcaption><\/figure>\n<p>That looks a bit friendlier, doesn\u2019t it? And although Thonny can do more, it\u2019s not complicated to use. If you can cope with uPyCraft, you will also find your way around Thonny in a few minutes.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Installation of Thonny<\/h3>\n\n<ol>\r\n<li>Download the installation file from <a href=\"https:\/\/thonny.org\/\" target=\"_blank\" rel=\"noopener\">https:\/\/thonny.org\/<\/a> (at the top of the page).<\/li>\r\n<li>Run the installation file and follow the instructions.<\/li>\r\n<li>Connect your ESP32 to the computer.<\/li>\r\n<li>Open Thonny and goe to Tools \u2192 Options \u2192 Interpreter.<\/li>\r\n<li>Select &#8220;MicroPython (generic)&#8221; and the correct port.<\/li>\r\n<\/ol>\r\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/06_thonny_select_interpreter.png\"><img loading=\"lazy\" decoding=\"async\" width=\"651\" height=\"505\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/06_thonny_select_interpreter.png\" alt=\"\" class=\"wp-image-12345\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/06_thonny_select_interpreter.png 651w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/06_thonny_select_interpreter-300x233.png 300w\" sizes=\"auto, (max-width: 651px) 100vw, 651px\" \/><\/a><\/figure>\n<p>That&#8217;s it and you&#8217;re ready to go.<\/p>\r\n\n<h3 class=\"wp-block-heading\">Uploading firmware with Thonny<\/h3>\n\n<p>To upload the firmware, go to Tools \u2192 Options \u2192 Interpreter, choose your board and click on &#8220;Install or Update Firmware&#8221;. Then choose the right port and firmware file (as described before for uPyCraft).<\/p>\r\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2022\/01\/firmware_thonny.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2022\/01\/firmware_thonny.png\" alt=\"Uploading firmware with Thonny\" class=\"wp-image-13537\" width=\"628\" height=\"398\" srcset=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2022\/01\/firmware_thonny.png 837w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2022\/01\/firmware_thonny-300x190.png 300w, https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2022\/01\/firmware_thonny-768x486.png 768w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/a><figcaption>Uploading firmware with Thonny<\/figcaption><\/figure><\/div>\n\n<h3 class=\"wp-block-heading\">The input() function<\/h3>\n\n<p>Another advantage of Thonny is that the <code>input()<\/code> function is implemented here. With uPyCraft this does not work (at least with the currently latest version). With the <code>input()<\/code> function you can enter data via the shell. The input is interpreted as a string and must be explicitly converted if necessary.<\/p>\r\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-group=\"input_example.py\" data-enlighter-title=\"input_example.py\">while True:\r\n    n = input(\"Input a number: \")\r\n    n = int(n)\r\n    if n &gt; 0:\r\n        if n &gt; 20:\r\n            print(n, \"is bigger than 20\")\r\n        elif n &gt; 10:\r\n            print(n, \"is bigger than 10\")\r\n        else:\r\n            print(n, \"is bigger than 0\")\r\n    elif n &lt;= 0:\r\n        print(n, \"is &lt;= 0\")\r\n    print(\"...........\")<\/pre>\r\n\n<h2 class=\"wp-block-heading\">Acknowledgement<\/h2>\n\n<p>I owe the queue on my post image to <a href=\"https:\/\/pixabay.com\/de\/users\/clker-free-vector-images-3736\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=312561\" target=\"_blank\" rel=\"noopener\">Clker-Free-Vector-Images<\/a> on <a href=\"https:\/\/pixabay.com\/de\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=312561\" target=\"_blank\" rel=\"noopener\">Pixabay.<\/a><\/p>\r\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a MicroPython crash course for people with Arduino\/C++ experience. I use the ESP32 as the MCU and uPyCraft as the IDE. <\/p>\n","protected":false},"author":1,"featured_media":12426,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[543,575],"tags":[1548,1543,1044,1546,1553,1550,1552,1547,1542,1549,1551,1545,1544],"class_list":["post-12609","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-boards-and-microcontrollers","category-software-and-tools","tag-arrays-en","tag-crash-course","tag-esp32-en","tag-firmware-en","tag-float-en","tag-input-en","tag-integer-en","tag-lists","tag-micropython-en","tag-mutable-objects","tag-sourcecodepro-en","tag-thonny-en","tag-upycraft-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MicroPython - Switching from Arduino &#8226; Wolles Elektronikkiste<\/title>\n<meta name=\"description\" content=\"This is a MicroPython crash course for people with Arduino\/C++ experience. I use the ESP32 as the MCU and uPyCraft as the IDE.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MicroPython - Switching from Arduino &#8226; Wolles Elektronikkiste\" \/>\n<meta property=\"og:description\" content=\"This is a MicroPython crash course for people with Arduino\/C++ experience. I use the ESP32 as the MCU and uPyCraft as the IDE.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino\" \/>\n<meta property=\"og:site_name\" content=\"Wolles Elektronikkiste\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-18T13:00:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-20T20:04:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Beitragsbild_mPython.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1340\" \/>\n\t<meta property=\"og:image:height\" content=\"1339\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Wolfgang Ewald\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Wolfgang Ewald\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"21 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino\"},\"author\":{\"name\":\"Wolfgang Ewald\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"headline\":\"MicroPython &#8211; Switching from Arduino\",\"datePublished\":\"2021-09-18T13:00:10+00:00\",\"dateModified\":\"2022-01-20T20:04:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino\"},\"wordCount\":3717,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/Beitragsbild_mPython.png\",\"keywords\":[\"Arrays\",\"crash course\",\"ESP32\",\"firmware\",\"float\",\"input()\",\"integer\",\"lists\",\"MicroPython\",\"mutable objects\",\"SourceCodePro\",\"Thonny\",\"uPyCraft\"],\"articleSection\":[\"Boards and Microcontrollers\",\"Software and tools\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino\",\"name\":\"MicroPython - Switching from Arduino &#8226; Wolles Elektronikkiste\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/Beitragsbild_mPython.png\",\"datePublished\":\"2021-09-18T13:00:10+00:00\",\"dateModified\":\"2022-01-20T20:04:14+00:00\",\"description\":\"This is a MicroPython crash course for people with Arduino\\\/C++ experience. I use the ESP32 as the MCU and uPyCraft as the IDE.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino#primaryimage\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/Beitragsbild_mPython.png\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/Beitragsbild_mPython.png\",\"width\":1340,\"height\":1339},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\\\/micropython-switching-from-arduino#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MicroPython &#8211; Switching from Arduino\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#website\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en\",\"name\":\"Wolles Elektronikkiste\",\"description\":\"Die wunderbare Welt der Elektronik\",\"publisher\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/en#\\\/schema\\\/person\\\/b774e4d64b4766889a2f7c6e5ec85b46\",\"name\":\"Wolfgang Ewald\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"url\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"contentUrl\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\",\"width\":512,\"height\":512,\"caption\":\"Wolfgang Ewald\"},\"logo\":{\"@id\":\"https:\\\/\\\/wolles-elektronikkiste.de\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/cropped-Logo-1.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MicroPython - Switching from Arduino &#8226; Wolles Elektronikkiste","description":"This is a MicroPython crash course for people with Arduino\/C++ experience. I use the ESP32 as the MCU and uPyCraft as the IDE.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino","og_locale":"en_US","og_type":"article","og_title":"MicroPython - Switching from Arduino &#8226; Wolles Elektronikkiste","og_description":"This is a MicroPython crash course for people with Arduino\/C++ experience. I use the ESP32 as the MCU and uPyCraft as the IDE.","og_url":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino","og_site_name":"Wolles Elektronikkiste","article_published_time":"2021-09-18T13:00:10+00:00","article_modified_time":"2022-01-20T20:04:14+00:00","og_image":[{"width":1340,"height":1339,"url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Beitragsbild_mPython.png","type":"image\/png"}],"author":"Wolfgang Ewald","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Wolfgang Ewald","Est. reading time":"21 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino#article","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino"},"author":{"name":"Wolfgang Ewald","@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"headline":"MicroPython &#8211; Switching from Arduino","datePublished":"2021-09-18T13:00:10+00:00","dateModified":"2022-01-20T20:04:14+00:00","mainEntityOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino"},"wordCount":3717,"commentCount":0,"publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Beitragsbild_mPython.png","keywords":["Arrays","crash course","ESP32","firmware","float","input()","integer","lists","MicroPython","mutable objects","SourceCodePro","Thonny","uPyCraft"],"articleSection":["Boards and Microcontrollers","Software and tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino","url":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino","name":"MicroPython - Switching from Arduino &#8226; Wolles Elektronikkiste","isPartOf":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#website"},"primaryImageOfPage":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino#primaryimage"},"image":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino#primaryimage"},"thumbnailUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Beitragsbild_mPython.png","datePublished":"2021-09-18T13:00:10+00:00","dateModified":"2022-01-20T20:04:14+00:00","description":"This is a MicroPython crash course for people with Arduino\/C++ experience. I use the ESP32 as the MCU and uPyCraft as the IDE.","breadcrumb":{"@id":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino#primaryimage","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Beitragsbild_mPython.png","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2021\/08\/Beitragsbild_mPython.png","width":1340,"height":1339},{"@type":"BreadcrumbList","@id":"https:\/\/wolles-elektronikkiste.de\/en\/micropython-switching-from-arduino#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/wolles-elektronikkiste.de\/en"},{"@type":"ListItem","position":2,"name":"MicroPython &#8211; Switching from Arduino"}]},{"@type":"WebSite","@id":"https:\/\/wolles-elektronikkiste.de\/en#website","url":"https:\/\/wolles-elektronikkiste.de\/en","name":"Wolles Elektronikkiste","description":"Die wunderbare Welt der Elektronik","publisher":{"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wolles-elektronikkiste.de\/en?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/wolles-elektronikkiste.de\/en#\/schema\/person\/b774e4d64b4766889a2f7c6e5ec85b46","name":"Wolfgang Ewald","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","url":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","contentUrl":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png","width":512,"height":512,"caption":"Wolfgang Ewald"},"logo":{"@id":"https:\/\/wolles-elektronikkiste.de\/wp-content\/uploads\/2019\/03\/cropped-Logo-1.png"}}]}},"_links":{"self":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/12609","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/comments?post=12609"}],"version-history":[{"count":0,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/posts\/12609\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media\/12426"}],"wp:attachment":[{"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/media?parent=12609"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/categories?post=12609"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wolles-elektronikkiste.de\/en\/wp-json\/wp\/v2\/tags?post=12609"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}