Arduino Sound Sensor

From wikiluntti
Revision as of 17:12, 18 November 2024 by Mol (talk | contribs) (→‎Code 1)

Introduction

Simple sound sensor; output True or False.

Code 1. The simple

Tutorial page: https://arduinogetstarted.com/tutorials/arduino-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");
  }

}


Exercises

Code 1

Turn on the LEDs while listening the sound.