Created
April 30, 2017 01:03
-
-
Save q40603/991c4a549e7711c005c32296ff2c3255 to your computer and use it in GitHub Desktop.
blink and ring when the magnitude of noise is over 40 db
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
const int buzzer = 8; | |
// the setup function runs once when you press reset or power the board | |
void setup() { | |
// initialize digital pin LED_BUILTIN as an output. | |
pinMode(LED_BUILTIN, OUTPUT); | |
pinMode(buzzer,OUTPUT); | |
} | |
// the loop function runs over and over again forever | |
void loop() { | |
char a[4]; | |
char b[3]={'0','4','0'}; | |
scanf("%c%c%c",&a[0],&a[1],&a[2]); | |
for(int j=0;j<3;j++){ | |
if(a[j]>b[j]){ | |
for(int i=0;i<30;i++){ | |
digitalWrite(LED_BUILTIN, HIGH); | |
tone(buzzer,1000); | |
delay(100); // wait for a second | |
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW | |
tone(buzzer,500); | |
delay(100); | |
} | |
noTone(buzzer); | |
break; | |
} | |
else if(a[j]<b[j]) break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment