Hi everyone, i am using the math.h or the first time and when the arduino does the math the answers of the arduino and the calculator have atleast a difference of 2. Thats a big difference which i dont want.Below is the code i used for doing the math.
#include <math.h>
double u;
double t;
double a;
double f;
int m = 4;
int v = 0;
double g = 9.8;
int d = 1;
int AOF = 70;
void setup(){
Serial.begin(9600);
u = sqrt((g*d)/sin(2*AOF));
Serial.print("Velocity = ");
Serial.println(u);
Serial.println();
t = 2*(u*sin(AOF))/g;
Serial.print("Time = ");
Serial.println(t);
Serial.println();
a = -1*((v-u)/t);
Serial.print("Acceleration = ");
Serial.println(a);
Serial.println();
f = m*a;
Serial.print("Force = ");
Serial.println(f);
}
void loop(){
}
These are the answers i get form the arduino-
velocity = 3.16
time = 0.5
acceleration = 6.33
force = 25.33
These are the answers from the calc -
velocity = 3.95
time = 0.7
acceleration = 5.somthing (dont remember)
force = 23.something
I coudnt find out wat i was doing wrong, plz give me ur advices on how to get the arduino answer as close as i can to the calculators or is this the best arduino can do. Plz need help.