This project utilizes the Raspberry Pi Pico microcontroller alongside a MPU-6050 chip to create a lightsaber using PlatformIO/VS Code with earlephilhower's arduino-pico core.
The MPU6050_light library is used to get orientation data.
These steps were written to try to be platform-agnostic, but may need to be modified for your needs. This software should work without modification if the wiring guide is followed.
- Software: Visual Studio Code, PlatformIO Extension
- Clone the repo:
git clone https://github.com/adih-20/saber-core.git
-
Import
saber-core
into PlatformIO/VSCode. -
Build and upload to Pico.
When switched on, the lightsaber should glow blue.
To switch colors, hold the lightsaber upside down (with the hilt facing the sky) for five seconds, which will cause the colors (Red, Orange, Green, Blue, Cyan, Purple, White) to switch every two seconds.
The software has an inbuilt watchdog to check for I2C communication errors with the MPU-6050. If any occur, the lightsaber will begin flashing red, indicating that the lightsaber must be manually restarted.
This project uses the following components:
-
Raspberry Pi Pico microcontroller
-
MPU-6050 Accelerometer/Gyroscope
-
SMD5050 LED Strip (not the NeoPixel!)
-
3x Logic Level N-MOSFET (I used the FQU13N10LTU, though you are welcome to use any other)
-
DC-DC Boost Converter (make sure it steps up the voltage, not steps down)
-
3x AA batteries
OPTIONAL
- SPST switch (strongly recommended to switch lightsaber on and off)
If you change any of the connections (with the exception of ground), make sure to update the code with your changes!
High-priority:
- Add over-temperature protection
Low-priority:
- Add flash-to-crash functionality
- Implement audio output
This project is licensed under the GPLv3.