Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
A1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ndl
2024-projects
A1
Commits
48dc7fa5
Commit
48dc7fa5
authored
5 months ago
by
Yuliia Denysiuk
Browse files
Options
Downloads
Patches
Plain Diff
Replace feasability_study_1.ino
parent
83c4a4a4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
feasability_study_1.ino
+14
-13
14 additions, 13 deletions
feasability_study_1.ino
with
14 additions
and
13 deletions
feasability_study_1.ino
+
14
−
13
View file @
48dc7fa5
...
@@ -10,7 +10,7 @@ BH1750 lightsens2(0x5C);
...
@@ -10,7 +10,7 @@ BH1750 lightsens2(0x5C);
Servo
servo1
;
Servo
servo1
;
Servo
servo2
;
Servo
servo2
;
int
angle
=
1
0
;
int
angle
=
9
0
;
int
stepSize
=
5
;
// Degree of movement per loop iteration
int
stepSize
=
5
;
// Degree of movement per loop iteration
void
setup
(){
void
setup
(){
...
@@ -54,10 +54,9 @@ void setup(){
...
@@ -54,10 +54,9 @@ void setup(){
}
}
}*/
}*/
/*int difToMove (int lux1, int lux2) {
int
difToMove
(
int
lux1
,
int
lux2
)
{
int step = (lux2 - lux1)/10;
return
(
lux2
-
lux1
)
/
10
;
return step;
}
}*/
void
loop
()
{
void
loop
()
{
...
@@ -66,12 +65,14 @@ void loop() {
...
@@ -66,12 +65,14 @@ void loop() {
uint16_t
lux1
=
lightsens1
.
readLightLevel
();
uint16_t
lux1
=
lightsens1
.
readLightLevel
();
uint16_t
lux2
=
lightsens2
.
readLightLevel
();
uint16_t
lux2
=
lightsens2
.
readLightLevel
();
Serial
.
printf
(
"23=%d, 5c=%d
\n
"
,
lux1
,
lux2
);
Serial
.
printf
(
"23=%d, 5c=%d
\n
"
,
lux1
,
lux2
);
// int step = difToMove(lux1, lux2);
int
step
=
difToMove
(
lux1
,
lux2
);
// Serial.printf("%d \n", step);
Serial
.
printf
(
"%d
\n
"
,
step
);
Serial
.
printf
(
"%d
\n
"
,
angle
);
// rotate();
// rotate();
// Compare light levels and adjust servo1's angle
/*
// Compare light levels and adjust servo1's angle
if (lux1 < lux2) {
if (lux1 < lux2) {
// Move to the right (increase angle) if sensor1 detects less light
// Move to the right (increase angle) if sensor1 detects less light
if (angle < 180) {
if (angle < 180) {
...
@@ -89,18 +90,18 @@ void loop() {
...
@@ -89,18 +90,18 @@ void loop() {
else {
else {
// Stop the servo movement if the light levels are equal
// Stop the servo movement if the light levels are equal
servo1.write(angle); // Hold the current position
servo1.write(angle); // Hold the current position
}
}
*/
/*
if (angle <=
36
0 && angle >= 0) {
if
(
angle
<=
18
0
&&
angle
>=
0
)
{
Serial
.
printf
(
"andle accepted %d"
,
angle
);
Serial
.
printf
(
"andle accepted %d"
,
angle
);
if
(
step
<
0
)
{
if
(
step
<
0
)
{
angle = m
in
(0, angle + step);
angle
=
m
ax
(
0
,
angle
+
step
);
}
}
else
if
(
step
>
0
)
{
else
if
(
step
>
0
)
{
angle = m
ax(36
0, angle + step);
angle
=
m
in
(
18
0
,
angle
+
step
);
}
}
servo1
.
write
(
angle
);
servo1
.
write
(
angle
);
}
*/
}
delay
(
100
);
delay
(
100
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment