# marciopp

Member Since: August 7, 2010

Country: United States

• Did some alterations on .ino. Maybe it runs directly, without alterations now.

• Arduino code trial uploaded on Github:

https://github.com/marciopp/SparkfunBag

Code was not verified.

• Matlab code on Github:

https://github.com/marciopp/SparkfunBag

As soon as I have time I will port to Arduino as the code is simple and moving averages have specific libraries already coded.

• Hi, I did not have time to port to Arduino, but the code is very simple. I am posting today, because is the last day… Approach is three moving averages to smooth the instantaneous acceleration delta and a lower limit to discriminate low acceleration change that is not a hit. Parameters were established on trial and error to better suit the known results. Code was tested on Matlab (have fun):

cont=0; % hit count delta=0; % acceleration instantaneous delta finalmean=0; % acceleration smoothed firstmean=90; % parameter for first moving average secondmean=110; % parameter for second moving average thirdmean=30; % parameter for third moving average lowerlimit=80; % hits are above this limit for i=1:length(x)-1; delta(i)=abs(x(i+1)-x(i))+ abs(y(i+1)-y(i)) + abs(z(i+1)-z(i)); end; finalmean=movmean(movmean(movmean(delta,firstmean,‘omitnan’),secondmean,‘omitnan’),thirdmean,‘omitnan’); for i=1:length(finalmean)-2; if (finalmean(i+2)<finalmean(i+1)) && (finalmean(i+1)>finalmean(i)) && (finalmean(i+1) > lowerlimit); cont=cont+1; end; end; display(cont);

x,y and z are your inputs and cont will give you the hits. On Arduino I believe it can count the hit in real time, after less than 1 second of turned on. Results: 3: 77 (77), 4: 81 (81), 5: 91 (93), 6: 79 (79), Mistery 1: 190, Mistery 2: 161.

• Guess where is the other horn ?

No public wish lists :(

In 2003, CU student Nate Seidle blew a power supply in his dorm room and, in lieu of a way to order easy replacements, decided to start his own company. Since then, SparkFun has been committed to sustainably helping our world achieve electronics literacy from our headquarters in Boulder, Colorado.

No matter your vision, SparkFun's products and resources are designed to make the world of electronics more accessible. In addition to over 2,000 open source components and widgets, SparkFun offers curriculum, training and online tutorials designed to help demystify the wonderful world of embedded electronics. We're here to help you start something.