Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void test_accelerometer_module(void) {
- // Display the acclerometer on the LCD
- int k = 0;
- int count = 0;
- long int sum = 0;
- long int average;
- setStrings("Tilt", "");
- // Loop to constantly display acceleration
- for (;;){
- obtainAccelData(axraw, ayraw, azraw); // Get the raw acceleration data
- k = accelToDegrees(axraw, azraw); // Read in the index which corresponds to the degree
- //average = k; // intially display the accel
- // Perform the average over 200 samples
- sum = sum+k; // Add the current degree to the cumulative sum
- if (count == 199){ // Wait to take the sample of 200 values
- average = sum/200; // Calculate the average of these samples
- lcdTop1DP(average); // Display the accel pretty
- count = 0; // Reset the count, sum and average
- sum = 0;
- average = 0;
- }
- else { // If 200 samples haven't been taken, increment the count
- count = count+1;
- }
- //dispTop(k);
- //dispTop(*azraw); // Displays the x acceleration data
- //setSevenSegDec(*axraw); // For now, display also on 7 seg
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement