Untitled
unknown
plain_text
a year ago
396 B
8
Indexable
const int relayPin = 13;
const int soundSensorPin = 2;
int soundState = 0;
int lastSoundState = 0;
void setup() {
pinMode(relayPin, OUTPUT);
pinMode(soundSensorPin, INPUT);
}
void loop() {
soundState = digitalRead(soundSensorPin);
if (soundState == HIGH && lastSoundState == LOW) {
digitalWrite(relayPin, !digitalRead(relayPin));
delay(200);
}
lastSoundState = soundState;
}Editor is loading...
Leave a Comment