Skip to content
Snippets Groups Projects
Commit 48dc7fa5 authored by Yuliia Denysiuk's avatar Yuliia Denysiuk
Browse files

Replace feasability_study_1.ino

parent 83c4a4a4
No related merge requests found
......@@ -10,7 +10,7 @@ BH1750 lightsens2(0x5C);
Servo servo1;
Servo servo2;
int angle = 10;
int angle = 90;
int stepSize = 5; // Degree of movement per loop iteration
void setup(){
......@@ -54,10 +54,9 @@ void setup(){
}
}*/
/*int difToMove (int lux1, int lux2) {
int step = (lux2 - lux1)/10;
return step;
}*/
int difToMove (int lux1, int lux2) {
return(lux2 - lux1)/10;
}
void loop() {
......@@ -66,12 +65,14 @@ void loop() {
uint16_t lux1 = lightsens1.readLightLevel();
uint16_t lux2 = lightsens2.readLightLevel();
Serial.printf("23=%d, 5c=%d \n", lux1, lux2);
// int step = difToMove(lux1, lux2);
// Serial.printf("%d \n", step);
int step = difToMove(lux1, lux2);
Serial.printf("%d \n", step);
Serial.printf("%d \n", angle);
// rotate();
// Compare light levels and adjust servo1's angle
/* // Compare light levels and adjust servo1's angle
if (lux1 < lux2) {
// Move to the right (increase angle) if sensor1 detects less light
if (angle < 180) {
......@@ -89,18 +90,18 @@ void loop() {
else {
// Stop the servo movement if the light levels are equal
servo1.write(angle); // Hold the current position
}
}*/
/* if (angle <= 360 && angle >= 0) {
if (angle <= 180 && angle >= 0) {
Serial.printf("andle accepted %d", angle);
if (step < 0) {
angle = min(0, angle + step);
angle = max(0, angle + step);
}
else if (step > 0) {
angle = max(360, angle + step);
angle = min(180, angle + step);
}
servo1.write(angle);
}*/
}
delay(100);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment