Skip to content

Instantly share code, notes, and snippets.

View bagdonas's full-sized avatar

Julius Bagdonas bagdonas

  • Vilnius
View GitHub Profile
@bagdonas
bagdonas / test-hall-sensor.ino
Created February 5, 2021 22:16
Test hall effect sensor (like A1324LUA-T). Attempt to make reading linear (based on distance)
#include <math.h>
const float POW_CBRT = 1.0f / 3.0f;
const float R_MAX = pow(0.01f, POW_CBRT);
float calcR(int value) {
// I = r^-3
// r = cbrt(1 / I)
float I = (value / 1023.0f - 0.5f) * 2.0f; // [-1..1]
float r = pow(abs(I), -POW_CBRT);