Created
August 22, 2016 12:35
-
-
Save haru01/d085d4629357ac182b297b2e030f1208 to your computer and use it in GitHub Desktop.
ピコピコぴー
This file contains hidden or 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
#include <Tone.h> | |
#include "Ultrasonic.h" | |
Tone notePlayer; | |
Ultrasonic ultrasonic(7); | |
void setup(void) | |
{ | |
notePlayer.begin(8); | |
} | |
void loop(void) | |
{ | |
long range = ultrasonic.MeasureInCentimeters(); | |
long delay_length = range * 3 + 100; | |
if (range >= 1) { | |
notePlayer.play(2252,50); | |
delay(delay_length); | |
notePlayer.play(2000,50); | |
delay(delay_length); | |
} else { | |
notePlayer.play(2500,2000); | |
delay(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment