This repository was created from the Pybricks template
The intention of this activity is to learn about using different chatmodes in GitHub Copilot Chat to implement a new feature in an existing codebase. You can change the prompts as you see fit, but the goal is to use RefinePrompt, Plan, and Agent chatmodes in sequence to implement the new feature.
Make sure to check the robot name in the launch.json file and update it to match your hub.
-
Follow Python installation steps here 👇
-
Test the Robot Blink script as-is to see the existing robot blinking animation. here 👇
-
Change the chatmode to RefinePrompt
Prompt
Replace the robot blinking animation in robot_blink.py with a LEGO letter display where each letter (L-E-G-O) is built pixel-by-pixel with individual tiles dropping from top to bottom like Tetris pieces falling and stacking. Each dropped tile should stay lit and accumulate to form the complete letter before moving to the next letter.
- Switch to Plan chatmode and plan out the changes needed to implement the new LEGO letter display animation.
Prompt
Plan out the changes
- Switch to Agent Mode Prompt
Implement the changes planned, make sure to test by uploading to the hub
Create a new virtual environment, install the dependencies from requirements.txt, and open thefolder in VS Code.
python3 -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements.txtThis repository includes a simple MicroPython script for Pybricks hubs:
A script that prints "Hello World" and displays a blinking robot face using Matrix patterns on the LED display. The robot has sensors, eyes, and features that create a friendly animated face with periodic blinking.
A sample configuration for debugging Pybricks scripts directly from VS Code using the pybricksdev tool.
- F5 to start debugging in VS Code (ensure that you updated the launch.json with your hub name)
- In terminal:
pybricksdev run ble robot_blink.py -n "John" - Or run via USB connection:
pybricksdev run usb robot_blink.py
- Console prints "Hello World!" and animation status messages
- LED matrix displays a robot face with sensors, eyes, and features
- Eyes blink periodically (closed eyes are dimmer)
- Pattern loops continuously with "Blink!" messages until stopped
- LEGO SPIKE Prime Hub
- Not tested on other hubs but should work with minor adjustments
- Make sure your hub is powered on and connected before running the scripts.
- Check the Pybricks documentation for more information on supported features and limitations.
- When using Bluetooth, the Spike Prime Hub should be blinking blue to indicate it is in pairing mode.
The import errors shown in VS Code are normal - these scripts are designed to run on the MicroPython environment on the Pybricks hub, not in your local Python environment.