Linux #5 2018 – Listing Inbraakalarm
- October 18, 2018
- 0
const int micPin = A0;
const int ledPin = 13;
const int drempel = 5;
// Stel hiermee de gevoeligheid in. Lager is gevoeliger, minimumwaarde is 2.
int value1 = 0;
int value2 = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
value1 = analogRead(micPin);
delayMicroseconds(100);
value2 = analogRead(micPin);
if (abs(value2 – value1) >= drempel) {
Serial.print(“value1: “);
Serial.print(value1);
Serial.println();
Serial.print(“value2: “);
Serial.print(value2);
Serial.println();
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
}
}