Skip to content

Commit

Permalink
Enlarging sum variable to avoid overflow. #38
Browse files Browse the repository at this point in the history
Arduino UNO 16bit int overflows with a large summation, switching to int32_t
  • Loading branch information
Kevin J Walters committed Jan 3, 2024
1 parent 0c7e3bd commit 18bd185
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion software/ClawController/ClawController.ino
Original file line number Diff line number Diff line change
@@ -25,6 +25,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include <inttypes.h>

#if defined(ESP32)
#include <ESP32Servo.h>
#else
@@ -42,7 +44,8 @@
#define SERVO_MAX 180

int circular_buffer[BUFFER_SIZE];
int data_index, sum;
int32_t sum;
int data_index;
int flag=0;
Servo servo;

0 comments on commit 18bd185

Please sign in to comment.