Shop OBEX P1 Docs P2 Docs Learn Events
PBasic Math — Parallax Forums

PBasic Math

CenlasoftCenlasoft Posts: 265
edited 2008-07-14 14:32 in BASIC Stamp
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
·

Comments

  • JonathanJonathan Posts: 1,023
    edited 2008-07-14 14:32
    Curtis,

    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
Sign In or Register to comment.