Uploading Code

Transfer Fabrica control software to your Raspberry Pi Pico 2W

Before You Start

  • ✓ MicroPython installed on Pico 2W
  • ✓ Thonny IDE installed and connected
  • ✓ Fabrica source code downloaded
  • ✓ USB cable connected to Pico

Step 1: Download Fabrica Source Code

1

Visit GitHub Repository

Go to github.com/buildair-ai/fabrica

2

Download ZIP

Click the green Code button, then select Download ZIP

3

Extract Files

Unzip the downloaded file to a convenient location (e.g., Desktop or Documents)

Fabrica File Structure

The extracted folder contains the following MicroPython files:

fabrica/
├── main.py # Main program entry point (runs on boot)
├── config.py # Configuration settings (edit for your setup)
├── button.py # Button handler with polling & LED blinking
├── servo_controller.py # PCA9685 PWM driver control
├── motion_plan_executor.py # Execute motion sequences
├── motion_plan_storage.py # Persistent storage for sequences
├── config_mode.py # Interactive configuration mode
├── logger.py # Centralized logging system
├── Readme.md # Comprehensive documentation
└── fabrica.code-workspace # VS Code workspace configuration

Core Files (Required)

  • main.py: Entry point, initializes hardware
  • config.py: All hardware & timing settings
  • button.py: Short/long press detection
  • servo_controller.py: Parallel motor execution
  • motion_plan_executor.py: Sequential steps
  • motion_plan_storage.py: JSON persistence
  • config_mode.py: Record new sequences
  • logger.py: Debug output control

Supporting Files

  • Readme.md: Detailed usage guide
  • fabrica.code-workspace: VS Code setup
  • motion_plans.json: Created on device

Note: motion_plans.json is created automatically when you save sequences.

Step 2: Upload Files to Pico

Using VS Code? →
1

Open Thonny's File Manager

In Thonny, go to View → Files to open the file browser panel

💡 You should see two sections: "This computer" (your PC) and "Raspberry Pi Pico" (the device)

2

Navigate to Fabrica Folder

In the "This computer" section, navigate to where you extracted the Fabrica files

3

Upload Files

Select all 8 .py files, right-click, and choose "Upload to /"

  • ✓ main.py
  • ✓ config.py
  • ✓ button.py
  • ✓ servo_controller.py
  • ✓ motion_plan_executor.py
  • ✓ motion_plan_storage.py
  • ✓ config_mode.py
  • ✓ logger.py

⚠️ Upload to the root directory (/), not a subdirectory. This ensures files are found at runtime.

4

Verify Upload

Check the "Raspberry Pi Pico" section—you should see all 8 .py files listed

✓ Upload complete when all files appear in the device file list

Alternative: Manual File Upload

If Thonny's file browser doesn't work, you can upload files individually:

1

Open each .py file in Thonny (File → Open, select file from your computer)

2

With the file open, go to File → Save as...

3

Select "Raspberry Pi Pico" as the destination

4

Keep the original filename and save to the root directory

5

Repeat for all 8 Python files (.py extension)

Step 3: Test the Upload

Quick Import Test

In Thonny's Shell (bottom panel), type these commands to verify files are accessible:

>>> import main
>>> import config
>>> import servo_controller
>>> import button
>>> print("All files loaded successfully!")

If no errors appear, all files are uploaded correctly.

Understanding Auto-Run Behavior

How MicroPython Boots

When powered on, the Raspberry Pi Pico 2W automatically runs main.py if it exists.

Development Mode (Current State)

While connected to Thonny, main.py won't auto-run. This lets you test code interactively without reboots.

To manually run: Open main.py in Thonny and click Run (▶️)

Standalone Mode (After Setup)

Once you disconnect USB and power the Pico via external power supply, main.py will automatically run on boot. No computer needed!

How to trigger: Simply power cycle the Pico (unplug/replug power)

📁 File Management Tips

  • 1. Keep backups: Save a copy of your working config.py on your computer before making changes.
  • 2. Version control: If making major modifications, append version numbers to filenames (e.g., sequence_v2.py).
  • 3. Disable logging: Set ENABLE_LOGGING = False in config.py for production use to improve performance and reduce serial output.
  • 4. View storage usage: In Thonny Shell, run import os; print(os.statvfs('/')) to check available space.

✅ Code Upload Complete!

All Fabrica software is now on your Pico 2W. Before running, you need to configure your specific hardware setup.

Next: Proceed to Configuration to customize settings for your panel layout and servo channels.