Go Down

Topic: Help with a math project (Read 235 times) previous topic - next topic


Hey! I am currently working on a math project using the arduino, but i've run into a problem. What my code is suposed to do is take x and y coordinates and calculate them into angles. However, when the angles for the sinus go above 90 degrees, it outputs a wrong number. As far as I can tell, it takes whatever it is above the 90 degrees, and subtracts it from 90. What i want it to do is output the right number, but i've completely ran out of ideas. Can anyone help? If it doesn't make sense, sorry, but english isn't my first language
Code: [Select]
#include "math.h"

int x =7;
int y =8;

float r1 =11.4;
float r2 =11.9;
float a, b, c, d, e;

const float pi =3.14;

void setup() {



Serial.print("vinkel 1: ");
Serial.print("vinkel 2: ");


Apr 21, 2017, 05:49 pm Last Edit: Apr 21, 2017, 06:43 pm by jremington
What does your your pocket calculator give for sin(120) and sin(60)?

The built-in functions like acos() and atan() produce the same result for different inputs.
It is up to you to decide how to interpret the result, but consider using atan2() rather than atan().

Go Up