Skip to main content

Beetle S1 - Writing Your First Light Script

After completing the environment setup, you can start writing your own light effects.

Write a Simple Light Effect​

Create a new file in Thonny and enter the following code:

import ws2812
import time

# Initialize LED strip (assuming connected to GPIO4, 60 LEDs)
led_strip = ws2812.WS2812(pin=4, count=60)

# Light up one by one
for i in range(60):
led_strip[i] = (255, 0, 0) # Red
led_strip.show()
time.sleep_ms(50)

# Turn off one by one
time.sleep(1)
for i in range(60):
led_strip[i] = (0, 0, 0)
led_strip.show()
time.sleep_ms(50)

This code will light up the LED strip one by one in red, then turn them off one by one.

Test the Effect​

  1. Click the Run button in Thonny
  2. Observe if the LED strip lights up as expected
  3. If the effect works correctly, save it to Beetle S1

Save to Device​

  1. Click File → Save
  2. Save the file to the /apps/ directory
  3. Refer to the existing config.json format to add the new effect entry

Reference​

Next Step​

After writing your script, check out the Package & Share guide to share your effects with others.