Skip to content

Instantly share code, notes, and snippets.

@deviceplususer
Created January 8, 2020 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deviceplususer/3e188f43ceb42f618697f130ec5f6102 to your computer and use it in GitHub Desktop.
Save deviceplususer/3e188f43ceb42f618697f130ec5f6102 to your computer and use it in GitHub Desktop.
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