INT, BYTE, CHAR, help with maths.
folks,
i off on project.
this needs bit of maths behind , although think have part down, putting in way arduino understands bit difficult.
the sketch far work in progress, don't bombard me "things missing".
i posting here on need define/declare variables as.
now, trying build structures code maybe become better programmer. knows?
alas code called v1 - version 1.
hsi 1 of sub-routines. well, now.
it should self explanatory in case:
i have little accelerometer/gyro/thingy sitting there , turn on.
skipping "zero-ing" it, apart in code, works out how show attitude on led ring.
(from ada fruit , each led addressable, controllable, etc.. led neopixel)
given pitch 0 +90 or 0 -90 calculate how "share" leds values.
there 0 value offset tell program show level.
the other offset if led #1 not @ top. (not used yet)
roll shall hope same values.
excuse basic way have done now, code said: basic pitch.
there in lies problem.
0 - 30 1 led, 31 - 60 , 61 - 90 third.
not good.
yes, int() doesn't help.
so if (what seem remember "single precision") able work out if need show 2 led's.
but in arduino lingo?
i "need" -90 +90 range on these 2 axis.
sure can "cheat" , make 0 - 180 , "-90" comes out.
what ever.....
could please me small sticking point?
thanks in advance.
i off on project.
this needs bit of maths behind , although think have part down, putting in way arduino understands bit difficult.
the sketch far work in progress, don't bombard me "things missing".
i posting here on need define/declare variables as.
now, trying build structures code maybe become better programmer. knows?
alas code called v1 - version 1.
hsi 1 of sub-routines. well, now.
it should self explanatory in case:
i have little accelerometer/gyro/thingy sitting there , turn on.
skipping "zero-ing" it, apart in code, works out how show attitude on led ring.
(from ada fruit , each led addressable, controllable, etc.. led neopixel)
given pitch 0 +90 or 0 -90 calculate how "share" leds values.
there 0 value offset tell program show level.
the other offset if led #1 not @ top. (not used yet)
roll shall hope same values.
excuse basic way have done now, code said: basic pitch.
there in lies problem.
0 - 30 1 led, 31 - 60 , 61 - 90 third.
not good.
yes, int() doesn't help.
so if (what seem remember "single precision") able work out if need show 2 led's.
but in arduino lingo?
i "need" -90 +90 range on these 2 axis.
sure can "cheat" , make 0 - 180 , "-90" comes out.
what ever.....
could please me small sticking point?
thanks in advance.
you made far:
that little it. know 'x' , 'y' are, , don't know range of other variables or stand for. sorry, hope else can more useful.
you can start giving meaningful names, , write in comments (degrees or else).
code: [select]
int zvo = 3;
int os = 0;
int led_loop = 12;
int ql = led_loop/4;
...
// basic pitch
int _a1 = (x / (90/ql)) + zvo;
int _a2 = led_loop - _a1;
// basic roll
int _b1 = (y / (90/ql)) + zvo;
int _b2 = led_loop - _b1;
that little it. know 'x' , 'y' are, , don't know range of other variables or stand for. sorry, hope else can more useful.
you can start giving meaningful names, , write in comments (degrees or else).
Arduino Forum > Using Arduino > Programming Questions > INT, BYTE, CHAR, help with maths.
arduino
Comments
Post a Comment