Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Peguino Mikrofon Brick
#1
Peguino Mikrofon Brick

Dieser Peguino Baustein beinhaltet ein Mikrofon mit dem auf Geräusche reagiert werden kann, wie beispielsweise auf ein Händeklatschen.


[Image: Brick_Microphone_01b.png]


Beispiel:

Code:
/*
  Microphone Brick
  (C) 2018 by Peguino LTD
  Connect the Microphone Brick to port D2
  Version 1
 
  Note: Use the Serial Monitor to see the values. Press: Ctrl + Shift + M


  Peguino Uno ESP 32 Development Board Pinout
            ┌─╥─┐
  3.3     1 │     │ 30  5V
  GND     2 │     │ 29  GND
  GPIO15  3 │     │ 28  GPIO13
  GPIO2   4 │     │ 27  GPIO12
  GPIO4   5 │     │ 26  GPIO14
  GPIO16  6 │     │ 25  GPIO27
  GPIO17  7 │     │ 24  GPIO26
  GPIO5   8 │     │ 23  GPIO25
  GPIO18  9 │     │ 22  GPIO33
  GPIO19 10 │     │ 21  GPIO32
  GPIO21 11 │     │ 20  GPIO35
  GPIO3  12 │     │ 19  GPIO34
  GPIO1  13 │     │ 18  GPIO39
  GPIO22 14 │     │ 17  GPIO36
  GPIO23 15 │     │ 16  Chip enable
            └───┘
  Visit https://www.peguino.com          
*/

const int buttonPin = 23;     // GPIO 23 Pin

// ledPin refers 1:1 to ESP32 GPIO 12, 13 and 14
const int ledPin1 = 13; // red
const int ledPin2 = 12; // green
const int ledPin3 = 14; // blue
int buttonState = LOW;         // variable for reading the microphone status

void setup(){
  // initialize digital pin ledPin as an output.
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  digitalWrite(ledPin1, HIGH);
  digitalWrite(ledPin2, HIGH);
  digitalWrite(ledPin3, HIGH);

  pinMode(buttonPin, INPUT);   // initialize the Button Brick pin as an input
  Serial.begin (115200);        // Press Ctrl+Shift+M and set the serial monitor to the same baud rate!
  Serial.println("Peguino Microphone trigger monitor");
}

void loop(){
  // read the state of the microphone value:
  buttonState = digitalRead(buttonPin);

  // now check if the Microphone triggers on sound. If it is, the buttonState is LOW:
  if (buttonState != LOW) {
    digitalWrite(ledPin1, LOW);     // Red light on
   digitalWrite(ledPin2, HIGH);     // Green light off
  } else {
    digitalWrite(ledPin1, HIGH);    // Red light off
   digitalWrite(ledPin2, LOW);      // Green light on
   delay (1000);                    // Let green light shine for one second
  }
  Serial.println(buttonState);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)