PBasic Math
Cenlasoft
Posts: 265
Hello,
I am using a BSII, an ADC ic, and a tsl253 light to voltage sensor to create a colorimeter. I have a parallax LCD module (serial) and everything works great. I get 10 reading (3.94), but I need to average these readings and then display to the lcd. I need help with the math for pbasic. All my values are between 0.00 and 4.00.
Thanks,
Curtis
·
I am using a BSII, an ADC ic, and a tsl253 light to voltage sensor to create a colorimeter. I have a parallax LCD module (serial) and everything works great. I get 10 reading (3.94), but I need to average these readings and then display to the lcd. I need help with the math for pbasic. All my values are between 0.00 and 4.00.
Thanks,
Curtis
·
Comments
Since the BS doesn't have floating point math, I'll assume that the range you quote is converted from integer to floating point.
Also assuming you are using a 12 bit ADC, the maximum reading would be 4095, which multiplied by ten is a max of 40950, which fits in a word sized var. So, all you need to do is accumulate the readings in a word size var, then divide by ten. Then do whatever math you are doing now.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot