Skip to content

Commit ad6dd60

Browse files
Added imaged file system
1 parent 28b2109 commit ad6dd60

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed
Loading
Loading

content/micropython/03.micropython/02.environment/02.file-system/file-system.md

+17-16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ When working with MicroPython, we’re not limited to a single program file like
99

1010
In this article, we'll explore how the MicroPython file system works, how to organize files effectively, and the typical structure of MicroPython projects.
1111

12+
1213
## The MicroPython File System: Key Differences
1314

1415
In traditional Arduino programming, we upload a single compiled file directly to the microcontroller, where it runs immediately. In MicroPython we work within a file system that can store multiple files. This file system allows us to:
@@ -26,7 +27,7 @@ To interact with the MicroPython file system, we’ll use Arduino Labs for Micro
2627
2. **Upload and Download Files**: Use the file manager to upload files from our computer to the microcontroller or download files back to our computer.
2728
3. **Organize Files**: We can create folders and store multiple files, making it easy to organize our project.
2829

29-
![Accessing the file system.]()
30+
![IDE's File Manager](./assets/IDEFileManager.png)
3031

3132
## Basic MicroPython File Structure
3233

@@ -51,30 +52,30 @@ To run code from a separate script in our `main.py` file, we can follow the inst
5152

5253
1. Create a file named `my_new_script.py`, and add the following function:
5354

54-
```python
55-
def test():
56-
print("This runs from my_new_script.py")
57-
```
55+
```python
56+
def test():
57+
print("This runs from my_new_script.py")
58+
```
5859

5960
2. In `main.py`, we run some initial code and then switches to executing a function from `my_new_script.py`. Here's an example:
6061

61-
```python
62-
import my_new_script
63-
print("This runs from main.py")
62+
```python
63+
import my_new_script
64+
print("This runs from main.py")
6465

65-
my_new_script.test()
66-
```
66+
my_new_script.test()
67+
```
6768

6869
3. Check the REPL, we should see:
6970

70-
```bash
71-
This runs from main.py # executed from main.py
72-
This runs from my_new_script.py #executed from my_new_script.py
73-
```
71+
```bash
72+
This runs from main.py # executed from main.py
73+
This runs from my_new_script #executed from my_new_script
74+
```
7475

7576
Essentially, this is how [modules]() work. You import a module, and use a function from that module.
7677

77-
![Import code from a script.]()
78+
![Import code from a script.](assets/ImportScript.png)
7879

7980
## Example: Directly Executing a Script
8081

@@ -99,7 +100,7 @@ We can also directly execute another script stored on the device. For this examp
99100

100101
As a result, we should read `"I was run from main.py"` in the REPL. How this differs from the previous example, is that the `run_directly.py` script was just run from top to bottom, as opposed to importing a specific segment of code.
101102

102-
![Executing a script directly.]()
103+
![Executing a script directly.](assets/RunningScript.png)
103104

104105

105106
## Organizing Code with Modules and Libraries

0 commit comments

Comments
 (0)