I’m a student who just started learning Arduino, so I am still a beginner. I am working on a project where I have to sample impact accelerations. I used this blog to help guide my project:
I am particularly interested in the graph at the end of page 1 of the blog. This is my ultimate goal, to obtain a graph similar to that. I need to sample acceleration at a rate of above 10 kHz, and the graph is representative of a sampling rate of about 40 kHz, so I think it is possible. Attached is the code he used to get this graph. He used an Atmel ATmega328 with an Arduino Duemilanove in his setup, where I have an Arduino Mega 2560. We both use the same acclerometer and same external ADC. The way the code is supposed to work is it stores the data it reads from the accelerometer to an internal storage buffer.
My question is, how do I make this code work for my Mega2560? I do not know where in the code I am going wrong, although I do not completely understand the code. Right now when I run the code, I get numbers on the serial monitor that are not useful.
Thank you for any time and help, and please let me know if there is anything else I can describe or show to you to help.
When posting a small amount of code, just copy and paste it between code tags as explained in How to post code properly. Then we don't have to download it and open it in a text editor.
int i = storeIndex;
while (i != storeIndex-1)
Assume that storeIndex is zero. You will set i to zero and then the while loop will test for while i is not equal to -1. Bit of a problem because i won't be equal to -1 until you've gone round the loop 65535 times.