Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cozmo's rainbow cube #229

Open
Readyornot69 opened this issue Dec 31, 2024 · 0 comments
Open

Cozmo's rainbow cube #229

Readyornot69 opened this issue Dec 31, 2024 · 0 comments

Comments

@Readyornot69
Copy link

import cozmo
from cozmo.util import degrees
import time

Rainbow colors (Red, Orange, Yellow, Green, Blue, Indigo, Violet)

rainbow_colors = [
cozmo.lights.Color(red=255, green=0, blue=0), # Red
cozmo.lights.Color(red=255, green=165, blue=0), # Orange
cozmo.lights.Color(red=255, green=255, blue=0), # Yellow
cozmo.lights.Color(red=0, green=255, blue=0), # Green
cozmo.lights.Color(red=0, green=0, blue=255), # Blue
cozmo.lights.Color(red=75, green=0, blue=130), # Indigo
cozmo.lights.Color(red=238, green=130, blue=238) # Violet
]

def cozmo_program(robot: cozmo.robot.Robot):
# Find the first available cube
cube = robot.world.wait_for_observed_light_cube(timeout=30)

# If no cube is found, exit
if not cube:
    robot.say_text("No cube found").wait_for_completed()
    return

# Cycle through the rainbow colors for the cube's lights
for color in rainbow_colors:
    # Set the cube light color
    cube.set_light(color)
    time.sleep(1)  # Wait for 1 second before changing the color

# After cycling through, turn the lights off
cube.set_light(cozmo.lights.off)
robot.say_text("Rainbow pattern completed!").wait_for_completed()

cozmo.run_program(cozmo_program)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant