Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bcorn2
CS437 Final Project
Commits
af32d214
Commit
af32d214
authored
May 14, 2022
by
Ben Corn
Browse files
Add arduino code for soil moisture
parent
997e2ed7
Changes
1
Hide whitespace changes
Inline
Side-by-side
soil_moisture.ino
0 → 100644
View file @
af32d214
const
int
AirValue
=
683
;
//you need to replace this value with Value_1
const
int
WaterValue
=
260
;
//you need to replace this value with Value_2
int
soilMoistureValue
=
0
;
int
soilmoisturepercent
=
0
;
void
setup
()
{
Serial
.
begin
(
9600
);
// open serial port, set the baud rate to 9600 bps
}
void
loop
()
{
soilMoistureValue
=
analogRead
(
A0
);
//put Sensor insert into soil
//Serial.println(soilMoistureValue);
soilmoisturepercent
=
map
(
soilMoistureValue
,
AirValue
,
WaterValue
,
0
,
100
);
if
(
soilmoisturepercent
>=
100
)
{
Serial
.
println
(
"100 %"
);
}
else
if
(
soilmoisturepercent
<=
0
)
{
Serial
.
println
(
"0 %"
);
}
else
if
(
soilmoisturepercent
>
0
&&
soilmoisturepercent
<
100
)
{
Serial
.
print
(
soilmoisturepercent
);
Serial
.
println
(
"%"
);
}
delay
(
250
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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