Skip to content
Snippets Groups Projects
Commit 8a62b92a authored by James Immanuel Magsino's avatar James Immanuel Magsino
Browse files

testing

parent d9f56847
No related branches found
No related tags found
No related merge requests found
...@@ -35,5 +35,6 @@ ...@@ -35,5 +35,6 @@
"*.cpp": "cpp", "*.cpp": "cpp",
"*.h": "c", "*.h": "c",
"*.c": "c" "*.c": "c"
} },
"task.allowAutomaticTasks": "on"
} }
\ No newline at end of file
...@@ -156,14 +156,14 @@ void callback(uint gpio, uint32_t events) ...@@ -156,14 +156,14 @@ void callback(uint gpio, uint32_t events)
{ {
distance = 0; distance = 0;
} }
if (distance > 40) if (distance > 20)
{ {
distance = 40; distance = 20;
} }
distance = 40 - distance; distance = 20 - distance;
volatile int percentage = (distance / 20) * 100; volatile int percentage = (distance / 10) * 100;
rollingperc[pos] = percentage; rollingperc[pos] = percentage;
pos++; pos++;
...@@ -175,23 +175,23 @@ void callback(uint gpio, uint32_t events) ...@@ -175,23 +175,23 @@ void callback(uint gpio, uint32_t events)
int avg = (rollingperc[0] + rollingperc[1] + rollingperc[2] + rollingperc[3]) / 4; int avg = (rollingperc[0] + rollingperc[1] + rollingperc[2] + rollingperc[3]) / 4;
// if zwischen 90, 110, stop // if zwischen 90, 110, stop
double speed = 0.9 * ((avg - 100) * (avg - 100)) + 1500; // quadratisch double speed = 0.5 * ((avg - 100) * (avg - 100)) + 1000; // quadratisch
speed = speed + 10 * ((1.8 * avg) - 180); speed = speed + 10 * ((1.8 * avg) - 180);
// double speed = abs(70 * avg) + 2000; // linear // double speed = abs(70 * avg) + 2000; // linear
// speed += 70; // speed += 70;
set_speed(speed); set_speed(speed);
if (avg > 90 && avg < 110) if (avg == 100)
{ {
gpio_put(20, 0); gpio_put(20, 0);
gpio_put(21, 0); gpio_put(21, 0);
} }
else if (avg < 90) if (avg < 100)
{ {
motor_forward(); motor_forward();
} }
else if (avg > 110) else if (avg > 100)
{ {
motor_backward(); motor_backward();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment