Arduino Sound Sensor: Difference between revisions
From wikiluntti
(Created page with "== Introduction == Simple sound sensor; output True or False. == Code 1. The simple == <syntaxhighlight lang="C"> →* Created by ArduinoGetStarted.com * This example code is in the public domain * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-sound-sensor: // Arduino's pin connected to OUT pin of the sound sensor #define SENSOR_PIN 7 int lastState = HIGH; // the previous state from the input pin int currentState; // the current reading...") |
|||
Line 27: | Line 27: | ||
if (currentState){ | if (currentState){ | ||
Serial.println( currentState ); | Serial.println( currentState ); | ||
else{ | }else{ | ||
Serial.print("Schii"); | Serial.print("Schii"); | ||
} | } | ||
} | } | ||
</syntaxhighlight> |
Revision as of 17:11, 18 November 2024
Introduction
Simple sound sensor; output True or False.
Code 1. The simple
/*
* Created by ArduinoGetStarted.com
* This example code is in the public domain
* Tutorial page: https://arduinogetstarted.com/tutorials/arduino-sound-sensor
*/
// Arduino's pin connected to OUT pin of the sound sensor
#define SENSOR_PIN 7
int lastState = HIGH; // the previous state from the input pin
int currentState; // the current reading from the input pin
void setup() {
Serial.begin(9600);
pinMode(SENSOR_PIN, INPUT);
}
void loop() {
currentState = digitalRead(SENSOR_PIN);
if (currentState){
Serial.println( currentState );
}else{
Serial.print("Schii");
}
}