Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IOT_Arduino_Code
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
jananan.gugagayana
IOT_Arduino_Code
Commits
1425ecb7
Commit
1425ecb7
authored
Dec 19, 2020
by
nouman.ashraf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
Assessment_IOT_Code.ino
Assessment_IOT_Code.ino
+69
-0
No files found.
Assessment_IOT_Code.ino
0 → 100755
View file @
1425ecb7
#include<SPI.h>
#include <WiFiNINA.h>
#include "ThingSpeak.h"
unsigned
long
ChannelNo
=
1210180
;
const
char
*
WriteAPIKey
=
"122GT3DOPUPHMJVU"
;
WiFiClient
client
;
const
int
Trig_Pin
=
11
;
const
int
Echo_Pin
=
13
;
void
setup
()
{
pinMode
(
Trig_Pin
,
OUTPUT
);
pinMode
(
Echo_Pin
,
INPUT
);
char
ssid
[]
=
"EE-Hub-Eqp9"
;
char
pass
[]
=
"task-dub-ABACK"
;
int
status
=
WL_IDLE_STATUS
;
Serial
.
begin
(
9600
);
status
=
WiFi
.
begin
(
ssid
,
pass
);
Serial
.
println
(
"Connecting to network..."
);
if
(
status
!=
WL_CONNECTED
)
{
Serial
.
println
(
"Unable to connect to Wifi"
);
while
(
true
);
}
else
{
Serial
.
print
(
"Connection successful!"
);
Serial
.
print
(
"The IP Address is: "
);
Serial
.
println
(
WiFi
.
localIP
());
delay
(
10000
);
}
ThingSpeak
.
begin
(
client
);
}
void
loop
()
{
// put your main code here, to run repeatedly:
long
car
,
distanceCm
,
inches
;
digitalWrite
(
Trig_Pin
,
LOW
);
delayMicroseconds
(
2
);
digitalWrite
(
Trig_Pin
,
HIGH
);
delayMicroseconds
(
10
);
digitalWrite
(
Trig_Pin
,
LOW
);
car
=
pulseIn
(
Echo_Pin
,
HIGH
);
distanceCm
=
car
/
30
/
2
;
inches
=
car
/
11.81
/
2
;
if
(
distanceCm
<=
0
)
{
Serial
.
println
(
"Out of range"
);
}
else
{
Serial
.
print
(
inches
);
Serial
.
print
(
"inch: "
);
Serial
.
print
(
distanceCm
);
Serial
.
print
(
"cm"
);
Serial
.
println
();
}
delay
(
1000
);
Serial
.
println
(
"Posting "
+
String
(
distanceCm
,
2
)
+
" to ThingSpeak"
);
ThingSpeak
.
setField
(
2
,
String
(
distanceCm
,
2
));
ThingSpeak
.
writeFields
(
ChannelNo
,
WriteAPIKey
);
delay
(
30000
);
}
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