Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MY PROJECT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
james.clarke2
MY PROJECT
Commits
cdf7c1f6
Commit
cdf7c1f6
authored
Jan 05, 2021
by
james.clarke2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update My_Alarm_Sensor
parent
89478a1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
My_Alarm_Sensor
My_Alarm_Sensor
+18
-12
No files found.
My_Alarm_Sensor
View file @
cdf7c1f6
const int trigPin = 9;
const int echoPin = 10;
const int buzzer = 11;
const int ledPin = 13;
long duration;
int distance;
Serial.print("Connecting");
int safetyDistance;
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(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(echoPin, INPUT);
pinMode(buzzer, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
Serial.begin(9600);
}
}
void loop() {
void loop() {
...
@@ -36,7 +42,7 @@ void loop() {
...
@@ -36,7 +42,7 @@ void loop() {
distance= duration*0.034/2;
distance= duration*0.034/2;
safetyDistance = distance;
safetyDistance = distance;
if (safetyDistance <=
5
) {
if (safetyDistance <=
20
) {
digitalWrite(buzzer, HIGH);
digitalWrite(buzzer, HIGH);
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, HIGH);
}
}
...
@@ -49,6 +55,6 @@ void loop() {
...
@@ -49,6 +55,6 @@ void loop() {
Serial.println(distance);
Serial.println(distance);
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment