Ok, newbie programmer here.
I have a string on numbers (DataString) and I just want the Audrinio to take the average. How do I do that?
-Newbie
Ok, newbie programmer here.
I have a string on numbers (DataString) and I just want the Audrinio to take the average. How do I do that?
-Newbie
Please read the guidelines for posting on this Forum in the posts by Nick Gammon at the top of the page. You have not given enough information to even guess what your problem is, let alone a solution.
add up all the numbers and divide the sum by the count of the numbers
To get a more exact result (decimals) you might use floats or need to add a rounding strategy
1 3 5 7 8 9 10
sum = 43
count = 7
so the average = 43/7 = 6
or in float 43.0/7 = 6.142856...
hspeckma:
I have a string on numbers (DataString) and I just want the Audrinio to take the average. How do I do that?
chosenDataType Average=(D + a + t + a + S + t + r + i + n + g) / 10;
No that will never work you need it to be like this:-
int Average=('D' + 'a' + 't' + 'a' + 'S' + 't' + 'r' + 'i' + 'n' + 'g') / 10;
I think it fulfills the brief as being a stupid average.
Grumpy_Mike:
No that will never work you need it to be like this:-int Average=('D' + 'a' + 't' + 'a' + 'S' + 't' + 'r' + 'i' + 'n' + 'g') / 10;
I think it fulfills the brief as being a stupid average.
Nah, that's just mean
Patience is a virtue we don't see a lot of here from Newbies.
Or "persistence".
Except perhaps in the wrong direction.