0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

sphero boltで遊ぶAdvent Calendar 2024

Day 3

出力: Lチカ

Last updated at Posted at 2024-12-02

背景

メイン基板にはFrontとBackに2つのRGB-LEDが搭載されています。

241203.jpg

まずはLチカをしてみました。

Scratch

image.png

spheroV2

testにあったBoltTest.pyのコメントアウトを参考に同様な動作をするスクリプトを作成しました。

import time

from spherov2 import scanner
from spherov2.sphero_edu import EventType, SpheroEduAPI
from spherov2.types import Color

print("Testing Starting...")
print("Connecting to Bolt...")
toy = scanner.find_BOLT()

if toy is not None:
    print("Connected.")
    with SpheroEduAPI(toy) as droid:
        print("Testing Start...")

        droid.reset_aim()

        print("Testing Front LED")
        droid.set_front_led(Color(r=0, g=255, b=0)) #Sets front LED
        time.sleep(1)
        droid.set_front_led(Color(r=0, g=0, b=0)) #Sets front LED

        print("Testing Back LED")
        droid.set_back_led(Color(r=255, g=0, b=0)) #Sets back LED
        time.sleep(1)
        droid.set_back_led(Color(r=0, g=0, b=0)) #Sets back LED
        
        # droid.set_main_led(Color(r=255, g=0, b=0)) #Sets whole Matrix
        print("Testing End...")
  

実行結果はこちらのようになりました。

git\spherov2.py\spherov2\test>python BoltTest241202.py
Testing Starting...
Connecting to Bolt...
Connected.
Testing Start...
Testing Front LED
Testing Back LED
Testing End...

まとめ

spheroV2を用いて、sphero boltをpythonでLチカすることができました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?