Last active
July 26, 2018 03:34
-
-
Save atifahsuad/f5cbec61126b41c46312679bad6e9bab to your computer and use it in GitHub Desktop.
This example code is for Clap to Turn On The Light's Tutorial.
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
/* | |
This example code is for Clap to Turn On The Light's Tutorial. | |
Product page: | |
Maker UNO: https://www.cytron.io/p-maker-uno | |
Sound Sensor : https://www.cytron.io/p-so-mic-mod | |
Created by: | |
24/07/18 Suad Anwar, Cytron Technologies | |
*/ | |
int SoundSensor = 10; | |
int yellow = 4; | |
int value = 0; | |
int flag = 0; | |
void setup() { | |
pinMode(yellow, OUTPUT); | |
pinMode(SoundSensor, INPUT); | |
} | |
void loop() { | |
value = digitalRead(SoundSensor); // To get the Sound Sensor's value | |
if (value == 1) { | |
if (flag == 1) { | |
digitalWrite(yellow, HIGH); | |
flag = 0; | |
} | |
else if (flag == 0) { | |
digitalWrite(yellow, LOW); | |
flag = 1; | |
} | |
delay(200); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment