Help us understand the problem. What is going on with this article?

micro:bit+電流センサで電気調理器具のON→OFFを可視化する

概要

電気調理器具がON→OFFになった時に通知する仕組みを作る

背景

調理器具のタイマーのアラーム(例:電子レンジの「チン」音)は聴覚障害者は気づくことが出来ないため、視覚的に通知する仕組みを作りました。

処理の流れ

1.電流がON→OFFになる
2.micro:bitが上記を検知して、アニメーションで表示

動画

調理器具の
 電源ON:音符マーク♪
 電源ON→OFF:ハートマークのアニメーション
  完了に気付いてBボタンを押すまで点滅


主要部品

回路

下記を参考にさせてもらいました。
YHDC SCT-013-000 CT とArduinoで家庭内の電流を測定す

コード

■MakeCode
https://makecode.microbit.org/_hCz5T7DFsX7w

■javascript版

vChecker.js
let StateOFF: number[] = []
let DMY = 0
let IsON = 0
let tempV = 0
let TimeList: number[] = []
let count3 = 0
let AveV = 0
input.onButtonPressed(Button.A, function () {
    FuncIsONAve()
    basic.showNumber(AveV)
    basic.pause(1000)
})
function FuncIsONAve() {
    AveV = 0
    for (let i = 0; i < 3; i++) {
        tempV = Math.round(Math.map(pins.analogReadPin(AnalogPin.P0), 0, 1023, 0, 3300))
        AveV = AveV + tempV
        basic.pause(100)
    }
    AveV = AveV / 3
    if (AveV < 1600 || AveV > 1700) {
        IsON = 1
    } else {
        IsON = 0
    }
}
AveV = 0
count3 = 0
TimeList = [0, 0, 0]
StateOFF = [0, 0, 0]
IsON = 0
basic.showIcon(IconNames.Yes)
basic.forever(function () {
    FuncIsONAve()
    if (IsON == 1) {
        basic.showIcon(IconNames.EigthNote)
    }
    TimeList.push(IsON)
    DMY = TimeList.shift()
    basic.pause(2000)
    if (100 == TimeList[0] * 100 + TimeList[1] * 10 + TimeList[2] * 1) {
        while (!(input.buttonIsPressed(Button.B))) {
            basic.showIcon(IconNames.Heart)
            basic.pause(500)
            basic.showIcon(IconNames.SmallHeart)
        }
        basic.showIcon(IconNames.Yes)
    }
})

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away