/* The circuit: analog 3: audio in analog 4: ground analog 5: vcc */ // these constants describe the pins. They won't change: const int groundpin = 18; // analog input pin 4 -- ground const int powerpin = 19; // analog input pin 5 -- voltage const int AUDIOpin = A3; // audio in void setup() { // initialize the serial communications: Serial.begin(9600); // Provide ground and power by using the analog inputs as normal // digital pins. This makes it possible to directly connect the // breakout board to the Arduino. If you use the normal 5V and // GND pins on the Arduino, you can remove these lines. pinMode(groundpin, OUTPUT); pinMode(powerpin, OUTPUT); digitalWrite(groundpin, LOW); digitalWrite(powerpin, HIGH); pinMode(13, OUTPUT); } void loop() { // print the sensor values: Serial.print(analogRead(AUDIOpin)); Serial.println(); // delay before next reading: if ((analogRead(AUDIOpin))>558){ // ajustar segun sonido ambiente digitalWrite(13, HIGH); // set the LED on delay(500); // wait for a second digitalWrite(13, LOW); // set the LED off } delay(1); } |