Commit cdf7c1f6 authored by james.clarke2's avatar james.clarke2

Update My_Alarm_Sensor

parent 89478a1d
const int trigPin = 9;
const int echoPin = 10;
const int buzzer = 11;
const int ledPin = 13;
long duration;
int distance;
int safetyDistance;
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected, IP address: ");
Serial.println(WiFi.localIP());
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzer, OUTPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
}
void loop() {
......@@ -36,7 +42,7 @@ void loop() {
distance= duration*0.034/2;
safetyDistance = distance;
if (safetyDistance <= 5) {
if (safetyDistance <= 20) {
digitalWrite(buzzer, HIGH);
digitalWrite(ledPin, HIGH);
}
......@@ -49,6 +55,6 @@ void loop() {
Serial.println(distance);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment