CODE
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
#define led_pin 13 | |
#define sound 12 | |
boolean led=LOW; | |
boolean value_1; | |
boolean value_2; | |
void setup() { | |
pinMode(led_pin,OUTPUT); | |
pinMode(sound,INPUT); | |
digitalWrite(led_pin,led); | |
Serial.begin(9600); | |
} | |
void loop() { | |
value_1=digitalRead(sound); | |
Serial.print("value 1 is "); | |
Serial.println(value_1); | |
delay(20); | |
value_2=digitalRead(sound); | |
Serial.print("Value 2 is "); | |
Serial.println(value_2); | |
if(value_1!=value_2) | |
{ | |
led=!led; | |
digitalWrite(led_pin,led); | |
delay(100); | |
} | |
} |