Skip to content

Instantly share code, notes, and snippets.

@atifahsuad
Last active July 26, 2018 03:34
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 atifahsuad/f5cbec61126b41c46312679bad6e9bab to your computer and use it in GitHub Desktop.
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 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