From b06726839d7a265e7c0887e4c8741d08491d66f1 Mon Sep 17 00:00:00 2001 From: Mikhail Grushinskiy Date: Wed, 13 Nov 2024 12:09:04 -0500 Subject: [PATCH] Delete bbn_atomS3_lite_angle_unit directory --- .../bbn_atomS3_lite_angle_unit.ino | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 bbn_atomS3_lite_angle_unit/bbn_atomS3_lite_angle_unit.ino diff --git a/bbn_atomS3_lite_angle_unit/bbn_atomS3_lite_angle_unit.ino b/bbn_atomS3_lite_angle_unit/bbn_atomS3_lite_angle_unit.ino deleted file mode 100644 index 59eef66..0000000 --- a/bbn_atomS3_lite_angle_unit/bbn_atomS3_lite_angle_unit.ino +++ /dev/null @@ -1,39 +0,0 @@ -#include - -struct AngleInput { - int potentiometerPin = G8; // set the pin for the potentiometer. - int min_value = 110; - int max_value = 4095; - int avg_sensorValue; - int angle; -}; - -AngleInput angle_input; - -void setup() { - auto cfg = M5.config(); - AtomS3.begin(cfg); - Serial.begin(4800); - pinMode(angle_input.potentiometerPin, INPUT); // Sets the specified pin to input mode. -} - -void measure_angle(AngleInput* a) { - const int iter = 100; - a->avg_sensorValue = 0; - for (int i = 0; i < iter; i++) { - int cur_sensorValue = analogRead(a->potentiometerPin); // read the value from the sensor. - a->avg_sensorValue = a->avg_sensorValue + cur_sensorValue; - } - a->avg_sensorValue = a->avg_sensorValue / iter; - a->angle = (180 - (360 * (a->avg_sensorValue - a->min_value) / (a->max_value - a->min_value))); - if (a->angle > 180) a->angle = 180; - if (a->angle < -180) a->angle = -180; -} - -void loop() { - measure_angle(&angle_input); - //Serial.println(angle_input.avg_sensorValue); - Serial.println(angle_input.angle); - delay(200); -} -