Thread: Free Fall

  1. #1
    Registered User
    Join Date
    Oct 2017
    Posts
    39

    Free Fall

    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:
    Free Fall-capture-png

    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?

  2. #2
    Registered User
    Join Date
    Jun 2017
    Posts
    88
    #DEFINE is not #define I think, and generally constants are in all caps.
    The function definition for seconds is inside freeFall

    mag is undefined.

    int count is declared twice.
    Last edited by jack jordan; 11-03-2017 at 12:39 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trying to make letters fall
    By tpsynx in forum C Programming
    Replies: 14
    Last Post: 01-19-2016, 06:07 AM
  2. Replies: 6
    Last Post: 01-28-2013, 02:22 AM
  3. C++0x Concepts fall
    By Mario F. in forum General Discussions
    Replies: 32
    Last Post: 07-27-2009, 02:31 AM
  4. Microsoft Fall?
    By Sekti in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 02-25-2002, 04:21 PM

Tags for this Thread