Hello, we're doing a lab where this is our task:
We have an Arduino Esplora Board and we are going to drop it so far. The goal of the lab is to have a print statement output : "Ouch! I fell %lf meters in %lf seconds"...
Here are the steps:
// Step 1 - print statement saying I'm waiting with dots.
// -- Dots depend on number of lines you're reading from esplora. "Every 10 lines"
// -- Tolerance - when acelleration is constant.
// Step 2 - When you drop it, esplora will accelerate, will then print the "!".
// -- "!" prints based on number of lines you read, you will print based off of timing you read.
// -- fixed variable , print a "." or "!" every 200 miliseconds.
Here's sample output:
Here's the code I have so far:
Code:
#DEFINE grav 9.8
#include <stdio.h>
#include <math.h>
#define TRUE 1
double freeFall(double x, double y, double z);
int seconds(int tee);
int main(void) {
int t;
int count = 0;
double ax, ay, az;
while (TRUE)
{
scanf("%d,%lf,%lf,%lf", &t, &ax, &ay, &az);
printf("Echoing output: %d, %lf, %lf, %lf\n", t, ax, ay, az);
if(count > 0)
{
printf("\nOkay, I'm now receiving data");
int count = count + 1;
}
printf("I'm waiting ");
for(int i = 0; i < 10; i++)
{
printf(".");
}
}
printf("Ouch! I fell %d meters in %d seconds it was: %lf\n", seconds(t), mag(ax,ay,az));
return 0;
}
/* Put your functions here */
double freeFall(double x, double y, double z)
{
double accel = ((x*x)+(y*y)+(z*z));
double accel2 = sqrt(accel);
return accel2;
int seconds(int tee)
{
int seconds = tee/1000%60; // 1000 ms in 1 second.
return seconds;
}
}
I'm a little lost now. Any ideas?