You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/micropython/03.micropython/00.first-steps/00.intro-micropython/intro-micropython.md
+3-7
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ MicroPython is a lightweight implementation of Python 3 designed to run on micro
10
10
11
11
## MicroPython on Arduino Boards
12
12
13
-
![Placeholder graphic]()
13
+

14
14
15
15
When using MicroPython on Arduino boards, the software is first installed on your Arduino. This allows the board to interpret and run Python code. Once MicroPython is installed on your board (don't worry, we'll cover this [here]()), you can start writing and executing Python scripts instantly.
16
16
@@ -20,7 +20,7 @@ Unlike traditional development approaches, where you compile code and then flash
20
20
21
21
Once MicroPython is installed, you can start programming by writing scripts and uploading them to the board. These scripts are interpreted in real-time, meaning you can make quick changes and see immediate results, streamlining the development process.
22
22
23
-
![TODO: Image of code edit with immediate change]()
23
+

24
24
25
25
MicroPython also includes a simple file system where your scripts are stored. For example, when you write a script, it is saved directly on the board and can be executed immediately without compiling. You can also save other scripts that can be activated from the main script!
26
26
@@ -36,8 +36,6 @@ The MicroPython installation includes several key components:
36
36
37
37
2.**Base Modules**: MicroPython comes with built-in modules for working with hardware like pins, sensors, and communication protocols (I2C, SPI, etc.). This includes essential modules like `machine`, `network`, and `time`.
38
38
39
-
![TODO: A diagram showing how `boot.py` and `main.py` are loaded during the boot process and how they fit into the file system could be useful here.]()
40
-
41
39
## How to Program for MicroPython
42
40
43
41
Programming in MicroPython involves writing Python scripts in a text editor and then running them on your board. For this, we can use the [Arduino Lab for MicroPython]().
@@ -50,8 +48,6 @@ When writing MicroPython code, it's essential to think in terms of **modularity*
50
48
2.**Helper Modules**: Break down your code into smaller modules for specific tasks, such as controlling a sensor or managing a display. These modules can be imported into `main.py` as needed.
51
49
3.**Interrupts and Background Tasks**: If you're dealing with hardware, you may also need to work with interrupts or periodic tasks, which can be handled in dedicated modules.
52
50
53
-
![TODO: A flowchart here could be beneficial to illustrate how to structure a MicroPython project, with `main.py` at the top and helper modules branching off.]()
54
-
55
51
## MicroPython vs. C++ for Electronics Projects
56
52
57
53
MicroPython offers a different approach to programming compared to the traditional C++ used in Arduino development. Here are a few key comparisons:
@@ -60,6 +56,6 @@ MicroPython offers a different approach to programming compared to the tradition
60
56
-**Real-Time Interactivity**: With MicroPython, you can write and test code interactively, without needing to compile. This makes it faster to experiment and troubleshoot hardware setups.
61
57
-**Resource Efficiency**: C++ is more efficient in terms of memory and speed, making it a better option for projects that need to squeeze every bit of performance out of the hardware. MicroPython, on the other hand, prioritizes ease of development over raw performance, but it is still capable of handling many common hardware tasks.
62
58
63
-
![TODO: A side-by-side table comparing typical tasks (like reading a sensor or blinking an LED) in MicroPython and C++ could help illustrate the differences.]()
59
+
## Summary
64
60
65
61
In summary, MicroPython provides a powerful and flexible way to develop electronic projects, especially for those familiar with Python. Its ability to run on microcontrollers like Arduino boards makes it an attractive option for both beginners and experienced developers who want a fast and efficient workflow.
3. Press **INSTALL MICROPYTHON**. A loading animation will appear.
52
52
53
53
Once the firmware is installed a "Installation successful" message will appear. At this point you can safely close the installer as your board is now ready for tinkering!
@@ -63,20 +63,16 @@ First, download the latest version of [Arduino Lab for MicroPython](https://labs
63
63
64
64
#### MacOS
65
65
66
-
Run the downloaded file, and move it to your **"Applications"** folder.
67
-
68
-
![Installation MacOS.]()
66
+
Unzip the downloaded file, and run the application.
69
67
70
68
#### Windows
71
69
72
70
Unzip the downloaded file, and run the executable file (`.exe`).
73
71
74
-
![Installation Windows]()
75
-
76
72
### Online Setup
77
73
78
74
Alternatively, we can use the IDE without the need of installing anything. Simply visit the link below:
79
-
-[Arduino Lab for MicroPython (online).](https://lab-micropython.arduino.cc/).
75
+
-[Arduino Lab for MicroPython (online)](https://lab-micropython.arduino.cc/).
80
76
81
77
## Connecting Board and IDE
82
78
@@ -87,24 +83,20 @@ At this point in the tutorial, we have
87
83
We will now try out running a script on the board, to make sure things are working properly.
88
84
89
85
1. Plug the Arduino board into the computer using a USB cable.
90
-
![Connect board to computer.]()
91
-
2. Press the connection button on the top left corner of the window.
92
-
![Connect the editor to the board.]()
93
-
3. The connected Arduino board should appear, and we can click it:
94
-
![Select board.]()
86
+

87
+
2. Press the connection button on the top left corner of the window. The connected Arduino board should appear (by its port name), and we can click it:
88
+

95
89
96
90
We have now set up all necessary steps for running a script!
97
91
98
92
## Running a Test Script
99
93
100
94
With the installation and setup complete, let's try out running a very simple script: **Hello World!**
101
95
102
-
1. In the text area field of the editor, write the following: `print("Hello World!")`
103
-
![Write hello world.]()
104
-
2. Click on the play symbol (RUN).
105
-
![Run the script.]()
106
-
3. After running it, you should see `Hello World!` in the black box. This is the board sending the **"Hello World!"** back to you, because the script is run on the board, not on the computer. This means everything is successful, and you are ready to start writing MicroPython scripts!
107
-
![Hello world from the board.]()
96
+
1. In the text area field of the editor, write `print("Hello World!")`, and then click on the play symbol (RUN).
97
+

98
+
2. After running it, you should see `Hello World!` in the black box. This is the board sending the **"Hello World!"** back to you, because the script is run on the board, not on the computer. This means everything is successful, and you are ready to start writing MicroPython scripts!
99
+

Copy file name to clipboardExpand all lines: content/micropython/03.micropython/00.first-steps/02.first-script/first-script.md
+6-8
Original file line number
Diff line number
Diff line change
@@ -43,11 +43,9 @@ MicroPython is officially supported on several Arduino boards. Here’s a list o
43
43
44
44
1. Open the [Arduino Lab for MicroPython]() application.
45
45
2. Plug the Arduino board into the computer using a USB cable.
46
-
![Connect board to computer.]()
47
-
3. Press the connection button on the top left corner of the window.
48
-
![Connect the editor to the board.]()
49
-
4. The connected Arduino board should appear, and we can click it:
50
-
![Select board.]()
46
+

47
+
3. Press the connection button on the top left corner of the window. The connected Arduino board should appear (by its port name), and we can click it:
48
+

51
49
52
50
***Need help installing MicroPython on your board? Visit the [MicroPython installation guide]().***
53
51
@@ -56,7 +54,7 @@ MicroPython is officially supported on several Arduino boards. Here’s a list o
56
54
Once your board is connected, we can start writing code! Below you will find a basic example, that will flash the built in LED on your board every second.
57
55
58
56
1. First, open the `main.py` file on your board. We write in this file, because once saved, the code will run even if you reset the board.
59
-
![Open main.py file.]()
57
+

60
58
61
59
2. Copy and paste the following code into your editor:
62
60
```python
@@ -78,11 +76,11 @@ Once your board is connected, we can start writing code! Below you will find a b
78
76
***Note: The built-in LED pin varies from board to board. For example, on the Arduino Nano RP2040 Connect, the built-in LED is on pin `25`.***
79
77
80
78
3. Click the **Run** button in your editor to transfer the script to your board.
81
-
![Run the script.]()
79
+

82
80
83
81
Once the script is running, the LED on the board should start blinking at one-second intervals. This means our MicroPython script has loaded successfully.
Copy file name to clipboardExpand all lines: content/micropython/03.micropython/01.basics/00. digital-io/digital-io.md
+6-10
Original file line number
Diff line number
Diff line change
@@ -62,11 +62,9 @@ In this guide, we will be using some additional electronic components:
62
62
63
63
1. Open the [Arduino Lab for MicroPython]() application.
64
64
2. Plug the Arduino board into the computer using a USB cable.
65
-
![Connect board to computer.]()
66
-
3. Press the connection button on the top left corner of the window.
67
-
![Connect the editor to the board.]()
68
-
4. The connected Arduino board should appear, and we can click it:
69
-
![Select board.]()
65
+

66
+
3. Press the connection button on the top left corner of the window. The connected Arduino board should appear (by its port name), and we can click it:
67
+

70
68
71
69
***Need help installing MicroPython on your board? Visit the [MicroPython installation guide]().***
72
70
@@ -83,7 +81,7 @@ Connect an LED to the Arduino board, following the circuit diagram below:
83
81
- Connect the anode (+) of the LED to a digital output pin.
84
82
- Connect the cathode (-) of the LED through a resistor to `GND`.
85
83
86
-
![LED circuit.]()
84
+

87
85
88
86
***You can also use the built-in LED on your board, if you do not have an external LED.***
89
87
@@ -133,16 +131,14 @@ When a digital input pin is not connected to a definite HIGH or LOW voltage, it
133
131
134
132
These internal resistors are built into the microcontroller and can be enabled in your code, eliminating the need for external resistors.
135
133
136
-
![We can create a image here to explain that]()
137
-
138
134
### Example: Pull-Up Mode
139
135
140
136
In pull-up mode, the input pin is internally connected to a HIGH voltage level. When the input device (like a button) is activated and connects the pin to GND, the pin reads LOW (`0`).
141
137
142
138
- Connect one side of the button to **GND**.
143
139
- Connect the other side to a digital input pin.
144
140
145
-
![Pull-up mode circuit.]()
141
+

146
142
147
143
After completing the circuit diagram, copy the following code into your editor, and run the script.
148
144
@@ -181,7 +177,7 @@ In pull-down mode, the input pin is internally connected to GND. When the input
181
177
- Connect one side of the button to **3.3V** (or **5V**, depending on your board's logic level).
182
178
- Connect the other side to a digital input pin.
183
179
184
-
![Pull-down mode circuit.]()
180
+

185
181
186
182
After completing the circuit diagram, copy the following code into your editor, and run the script.
Copy file name to clipboardExpand all lines: content/micropython/03.micropython/01.basics/01. analog-io/analog-io.md
+6-8
Original file line number
Diff line number
Diff line change
@@ -54,11 +54,9 @@ In this guide, we will be using some additional electronic components:
54
54
55
55
1. Open the [Arduino Lab for MicroPython]() application.
56
56
2. Plug the Arduino board into the computer using a USB cable.
57
-
![Connect board to computer.]()
58
-
3. Press the connection button on the top left corner of the window.
59
-
![Connect the editor to the board.]()
60
-
4. The connected Arduino board should appear, and we can click it:
61
-
![Select board.]()
57
+

58
+
3. Press the connection button on the top left corner of the window. The connected Arduino board should appear (by its port name), and we can click it:
59
+

62
60
63
61
***Need help installing MicroPython on your board? Visit the [MicroPython installation guide]().***
64
62
@@ -87,7 +85,7 @@ For this example, we will need the following external components:
87
85
88
86
Connect the photoresistor to the Arduino board, following the circuit diagram below:
After completing the circuit diagram, copy the following code into your editor, and run the script.
93
91
@@ -126,7 +124,7 @@ PWM is especially useful in applications where true analog output is not possibl
126
124
127
125
The main advantage of PWM is that it allows you to control analog-like behavior using digital pins, adding versatility to your projects while keeping power consumption efficient.
128
126
129
-
![How PWM works.]()
127
+

130
128
131
129
### Code Example: Dimming an LED with PWM
132
130
@@ -141,7 +139,7 @@ For this example, we will need the following external components:
141
139
142
140
Connect the LED to the Arduino board, following the circuit diagram below:
143
141
144
-
![Photoresistor circuit.]()
142
+

145
143
146
144
After completing the circuit diagram, copy the following code into your editor, and run the script.
Copy file name to clipboardExpand all lines: content/micropython/03.micropython/01.basics/02. loops/loops.md
+3-8
Original file line number
Diff line number
Diff line change
@@ -43,11 +43,9 @@ MicroPython is officially supported on several Arduino boards. Here’s a list o
43
43
44
44
1. Open the [Arduino Lab for MicroPython]() application.
45
45
2. Plug the Arduino board into the computer using a USB cable.
46
-
![Connect board to computer.]()
47
-
3. Press the connection button on the top left corner of the window.
48
-
![Connect the editor to the board.]()
49
-
4. The connected Arduino board should appear, and we can click it:
50
-
![Select board.]()
46
+

47
+
3. Press the connection button on the top left corner of the window. The connected Arduino board should appear (by its port name), and we can click it:
48
+

51
49
52
50
***Need help installing MicroPython on your board? Visit the [MicroPython installation guide]().***
53
51
@@ -63,11 +61,8 @@ To better understand these loops, let’s imagine them as tasks at the supermark
63
61
64
62
-**for loops** - imagine walking down a supermarket aisle with a shopping list that specifies exactly how many items to pick up, one by one, in order. Once you’ve gathered all the items on your list, your task is complete. This is like a `for` loop iterating over a sequence, handling each specified item one at a time.
65
63
66
-
![How for loops work.]()
67
-
68
64
-**while loops** - imagine going to the supermarket to buy a certain product that’s on sale, as long as it stays in stock. You keep coming back, day after day, until the sale ends or the stock runs out. In a `while` loop, you keep “coming back” as long as a condition (like the sale continuing) remains true.
Copy file name to clipboardExpand all lines: content/micropython/03.micropython/01.basics/03.data-logger/data-logger.md
+3-5
Original file line number
Diff line number
Diff line change
@@ -45,11 +45,9 @@ MicroPython is officially supported on several Arduino boards. Here’s a list o
45
45
46
46
1. Open the [Arduino Lab for MicroPython]() application.
47
47
2. Plug the Arduino board into the computer using a USB cable.
48
-
![Connect board to computer.]()
49
-
3. Press the connection button on the top left corner of the window.
50
-
![Connect the editor to the board.]()
51
-
4. The connected Arduino board should appear, and we can click it:
52
-
![Select board.]()
48
+

49
+
3. Press the connection button on the top left corner of the window. The connected Arduino board should appear (by its port name), and we can click it:
50
+

53
51
54
52
***Need help installing MicroPython on your board? Visit the [MicroPython installation guide]().***
0 commit comments