LoginSignup
0
0

More than 3 years have passed since last update.

HaloCodeでエネルギーブレスレット

Posted at

前回の記事 halocode使ってみた!ではHaloCodeのセットアップやLチカのサンプルをやってみました

今回は加速度センサーを使ったサンプルを使ってみたいと思います

エネルギーブレスレット作成

HaloCodeを振ってエネルギーを貯めていくと、LEDがどんどん光っていくプログラムです

ブロック図

image.png

python code

energy_bracelet.py
# generated by mBlock5 for HaloCode
# codes make you happy

import event, halo
# initialize variables
test = 0

@event.button_pressed
def on_button_pressed():
    global test
    halo.led.off_all()
    test = 1
    while not 'test' == 20:
        if halo.motion_sensor.get_shake_strength() > 20:
            halo.led.show_single(test, 255, 0, 0)
            test = test + 1
            time.sleep(0.4)
        elif test == 

    halo.led.show_all(208, 2, 27)

...

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