Skip to content

Instantly share code, notes, and snippets.

@deviceplususer
Created January 8, 2020 10:36
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/07ea6a9257bd1cca977f3be550ba5f73 to your computer and use it in GitHub Desktop.
Save deviceplususer/07ea6a9257bd1cca977f3be550ba5f73 to your computer and use it in GitHub Desktop.
bool volumeSwitchState = digitalRead(VOLUME_SWITCH);//音量つまみスイッチの値を取得
if ( volumeSwitchState == 0 ) {//音量つまみスイッチがオンなら
tone(SPEAKER, frequency );//TOF距離センサーからの距離に応じた周波数の音を鳴らす
} else {
noTone(SPEAKER);//スイッチがオフなら音を止める
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment