Created
January 8, 2020 10:35
-
-
Save deviceplususer/3e188f43ceb42f618697f130ec5f6102 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float distance = sensor.readRangeSingleMillimeters();//TOF距離センサーの値を取得(単位:mm) | |
bool offsetButtonState = digitalRead(ORIGIN_BUTTON); //原点設定ボタンの状態を取得 | |
if ( offsetButtonState == 0 && prevButtonState == 1 )//原点設定ボタンが押されたら、 | |
{ | |
origin = distance;//originを現在のdistanceに変更 | |
} | |
prevButtonState = offsetButtonState;//prevButtonStateを更新 | |
float frequency = map(distance, origin, origin-heightRange, minFreq, maxFreq);//距離を周波数に変換 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment