diff options
Diffstat (limited to '5-microfono-relay.ino')
-rw-r--r-- | 5-microfono-relay.ino | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/5-microfono-relay.ino b/5-microfono-relay.ino new file mode 100644 index 0000000..83fe599 --- /dev/null +++ b/5-microfono-relay.ino @@ -0,0 +1,27 @@ +int sensorPin = A0; //KY-038 microphone +int relay = 13; +int sensorValue = 0; +bool on = false; + +void setup () +{ + pinMode (relay, OUTPUT); + digitalWrite (relay, LOW); + Serial.begin (9600); +} + +void loop () +{ + sensorValue = analogRead (sensorPin); + Serial.println (sensorValue, DEC); + if (sensorValue > 500) { + /*if (on == true) { + on = false; + } else { + on = true; + }*/ + on = !on; + } + digitalWrite (relay, on); + delay(100); +}
\ No newline at end of file |