Programmable Moon Phase Lamp - Seeed Studio XIAO ESP32C3 - dumpling—li - CodeCraft Hub
Scene: Education. Edge AI application on CodeCraft Hub for Education use cases.
Devices / BOM: Seeed Studio XIAO ESP32C3, Grove Shield for Seeed Studio XIAO, Grove - Universal 4 Pin Buckled 20cm Cable (5pcs), Type C to A
Education application on CodeCraft Hub. The "Programmable Moon Phase Lamp" bridges geography, coding, and daily life. Driven by ESP32-C3, it code-simulates moon phases to visualize Sun-Earth-Moon dynamics into dynamic light. Students explore lunar science through coding while crafting an aesthetic, educational desktop night light.
Documentation
1.1 Project Background
This project is suitable for technology enthusiasts to practice hands-on, and can also serve as an in-school STEAM elective or makerspace activity. We use the traditional festival "Mid-Autumn Festival" as a cultural vehicle, combining AI conversational programming, open-source hardware, and modern digital manufacturing. This is not a step-by-step "craft class," but rather an open workshop that encourages active exploration. In the process of independently making things, students not only experience the complete engineering loop from concept to physical object, but also complete a vivid cultural exploration through technology practice.
1.2 Project Overview
This series includes three independent projects based on the Seeed Studio XIAO-ESP32-C3 microcontroller. Students will use the Codecraft platform to collaborate with AI using natural language to generate code that drives different dynamic lighting effects, ultimately creating their own smart light installations. This document focuses on a detailed breakdown of the complete execution workflow of Project 1, "Programmable Moon Phase Lamp."
Project 1 "Programmable Moon Phase Lamp" : 3D-printed enclosure + WS2812 RGB LED strip.
Project 2 " Copper Wire Starry Sky Lamp " : Laser-cut array patterns + traditional copper wire decorative light string.
Project 3 "Glowing Mooncake Pendant" : 3D-printed miniature enclosure + COB light.
1.3 Teaching Implementation Plan
Target grade level: Grades 7-9 (ages 12+), no prior programming experience required.
Organization format: One person per kit. Ensure each student independently completes the full workflow of "writing prompts - hardware wiring - structural assembly - debugging and optimization."
Schedule: Half-day experience workshop (single session of 2-3 hours)
1.4 Core Objectives
AI Collaborative Programming: Learn prompt writing and use AI tools to assist with code writing and engineering debugging.
Hardware Control and Assembly: Master the wiring and control of ESP32-C3 with different LED strips, and complete compact-space assembly.
Engineering Practice and Troubleshooting: Master the basics of 3D printing and laser cutting, and develop independent troubleshooting skills.
Design Thinking: Break free from standard answers and create unique works through personalized lighting effects.
Cross-Disciplinary Cultural Integration: Combine technology creation with Mid-Autumn imagery to experience the cross-disciplinary fusion of technology and humanities.
Deploy steps
- 11
The "Programmable Moon Phase Lamp" is a cross-disciplinary maker work that integrates natural geography, software programming, and daily life. Based on ESP32-C3 controlling lighting effects, the project uses code to simulate the waxing and waning of the moon, translating the "Sun-Earth-Moon" orbital relationships into intuitive light and shadow. Students can explore the principles of moon phase changes through programming while creating a desktop night light that combines science popularization with ambient aesthetics, achieving a fusion of scientific inquiry and life aesthetics.
- Project Materials
2.1 Hardware and Structure
Microcontroller and expansion: Seeed Studio XIAO-ESP32-C3 x 1, XIAO expansion board x 1
Lighting: WS2812 addressable RGB LED strip (approximately 38-40 LEDs)
Structure: 3D-printed "moon phase lamp" enclosure (white/black PLA recommended)
Power supply: 3.7V lithium battery
2.2 Tools and Equipment
Computer / laptop
Type-C data cable (must support data transfer)
Wire strippers, scissors, hot glue gun
- Hardware Wiring
Microcontroller Assembly: Insert the XIAO ESP32-C3 vertically and firmly into the expansion board.
WS2812 LED Strip Connection
GND -> XIAO GND
B0 -> XIAO D0 (leave empty)
DIN -> XIAO D1
5V -> XIAO 5V
Computer Connection: Use a Type-C data cable to connect the expansion board to the computer for power and flashing.
Important Notes
Check direction: The LED strip signal is unidirectional -- you must connect to the input end marked with an arrow (->) (DIN)! Connecting it backwards will not light up.
Prevent short circuits: While powered on, never let the red wire (5V) and black wire (GND) touch each other, to avoid short-circuiting and burning the board.
- AI Programming Inquiry
Enter the platform and AI programming: Open the Codecraft platform in a browser and create a new project.
4.2 Conversational Programming (Prompt Examples)
Guide students to input prompts in stages, gradually verifying the hardware and achieving the final lighting effects.
Stage 1: Basic Illumination (Verify hardware communication)
"My microcontroller is a XIAO ESP32-C3, with a WS2812 LED strip connected to pin D1, totaling 40 LEDs. Please write a program to light up all LEDs in warm yellow."
Stage 2: Dynamic Breathing (Experience interactive control)
"Hardware conditions remain the same (C3 controller, D1 pin, 40 LEDs). Please have the LED strip slowly alternate between orange and dark red with a gradient, creating a breathing light effect with a cycle of about 3 seconds."
Stage 3: Moon Phase Simulation (Core project logic)
"Hardware conditions remain the same. On a pure black background, a cool blue-white arc of light slowly flows around the ring, with about 16 LEDs lit simultaneously, completing one revolution in 6 seconds, at 45% brightness, evoking a cool, serene, moonlight-spilling breathing sensation."
4.3 Independent Inquiry and Creation
After completing the basic levels, encourage s…
- Structural Design and 3D Printing
This project's structure is divided into an "outer frame" and a "moon surface," which can be directly downloaded and sliced for printing.
[Standard outer frame model]
[Basic moon surface model]
Teaching Tip If you are teaching in a classroom, it is recommended to directly provide students with the "standard outer frame" file to lower the barrier to entry. At the same time, you can guide students to use AI-generated 3D model websites or the bas-relief feature in Bambu Studio slicing software to convert 2D images into personalized 3D moon surface models, achieving personalized design.
- Structural Assembly and Final Debugging
Secure the LED strip: Evenly coil and secure the WS2812 LED strip along the inside of the frame, with the light-emitting side facing outward, taking care to avoid wires blocking the LEDs.
Install the moon surface: Align the 3D-printed "moon surface" with the outer frame and close them together.
Offline operation: Disconnect the computer data cable and use the 3.7V lithium battery for independent power supply. Power on and verify the moon phase lamp's lighting effect display.
- Online Flashing and Community Sharing
7.1 One-Click Online Flashing
Simply click the "One-Click Flash" button to download and run the program on your own hardware.
Flash firmware to your device (in-app tool on CodeCraft Hub).
Code snippet included — open the application page to copy it.
7.3 Publish and Open-Source Sharing
After completing debugging, you can publish your personalized moon phase lighting effect project to the App Square . Through open-source sharing, more people can experience the creative work with one-click flashing.