Shop OBEX P1 Docs P2 Docs Learn Events
Teaching my robot to hear, stuck again... — Parallax Forums

Teaching my robot to hear, stuck again...

PromagicPromagic Posts: 17
edited 2008-12-21 00:52 in BASIC Stamp
*Sigh*·I have been working and sleeping on this one for two weeks....with no avail...

···· I have been told before to make a filter, so·I have been attempting to make one..
First we have the raw 0-255 value from my adc connected to my sound sensor, my code attempts to make an average of about 100 added together adc values, then divides by 100.

I have been tinkering with everything. Any help would be awesome!
Sound:
FOR a = 1 TO 5
  b = b + adcBits                           'make a total of 5 adc values
IF a = 5 THEN
  mean1 = b / 5                             'devide the total by 5 to get an Average sound lvl
  'DEBUG DEC4 ? b, DEC4 ? adcBits, DEC4 ? mean1, DEC1 ? a, CR, CR
  'mean1 = 0                                'reset average
  b     = 0                                 'reset total
ENDIF
DEBUG DEC5 ? mean1, DEC3 ? adcBits ,DEC5 ? b, HOME
NEXT
'FOR a = 1 TO 100                           'Dads attempt
'   b = b + adcBits
'NEXT
'mean1 = b/100
'DEBUG DEC4 ? mean1, DEC5 ? b, DEC4 ? adcBits, CR
'RETURN


I have also attached some older versions of my code, 1.5 is the newest.

THANKS!!!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
···· -Devin


"I can only ask every question once."

Comments

  • John AbshierJohn Abshier Posts: 1,116
    edited 2008-12-21 00:52
    The sum of readings must fit in the variable. If b is a byte then the maximum value it can hold would be 255. If b is a word, the max value it can hold is 65536 or up to 8 readings max.

    John Abshier
Sign In or Register to comment.