4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

#M5StickV でLチカ

Last updated at Posted at 2020-08-21

概要

M5StickV のLEDでLチカをしてみました。
M5StickVには、RGBWで点灯するLEDが搭載されています。

環境

M5StickV
MicroPython v0.5.0-123-g859098d1e on 2020-08-21;

回路

Kendryte K210のIO_6~IO_9のIOがLED W2SA50TSと繋がっています。

クリップボード0211.jpg

Example.1

M5StickVのLEDを赤く点灯します。

クリップボード01_Red.jpg

from Maix import GPIO
from board import board_info

fm.register(board_info.LED_R, fm.fpioa.GPIO4)

led_r = GPIO(GPIO.GPIO4, GPIO.OUT)
led_r.value(0)

Example.2

M5StickVのAボタンを押すごとに色を変えてみました。

from fpioa_manager import *
from Maix import GPIO
from board import board_info

fm.register(board_info.BUTTON_A, fm.fpioa.GPIO1)
fm.register(board_info.BUTTON_B, fm.fpioa.GPIO2)
fm.register(board_info.LED_W, fm.fpioa.GPIO3)
fm.register(board_info.LED_R, fm.fpioa.GPIO4)
fm.register(board_info.LED_G, fm.fpioa.GPIO5)
fm.register(board_info.LED_B, fm.fpioa.GPIO6)

but_a=GPIO(GPIO.GPIO1, GPIO.IN, GPIO.PULL_UP)
but_b = GPIO(GPIO.GPIO2, GPIO.IN, GPIO.PULL_UP)
led_w = GPIO(GPIO.GPIO3, GPIO.OUT)
led_r = GPIO(GPIO.GPIO4, GPIO.OUT)
led_g = GPIO(GPIO.GPIO5, GPIO.OUT)
led_b = GPIO(GPIO.GPIO6, GPIO.OUT)

led_w.value(1) # LED OFF
led_r.value(1) # LED OFF
led_g.value(1) # LED OFF
led_b.value(1) # LED OFF

counter = 0
but_stu = 1

while(True):
    if but_a.value() == 0 and but_stu == 1:

        if led_w.value() == 1:        
            led_w.value(0)
        else:
            led_w.value(1)
        but_stu = 0
    if but_a.value() == 1 and but_stu == 0:
        but_stu = 1

参考

4
3
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?