gauranggoyal123 / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

math problem #1110

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. i use  float pinFloat1 = sensorValue1* (90 / 1023.0); to get an angle
2.then i use   float R1=cos(pinFloat1);
3.

What is the expected output? What do you see instead?
at 0 degree i am getting 1 that is correct, but anything else is not at some 
point it was giving me negative numbers

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?
i think version 1.0.1 on win7 i tried on both uno and mega 2560

Please provide any additional information below.
i am new at this just trying to make it do math...

Original issue reported on code.google.com by shaychi...@gmail.com on 13 Nov 2012 at 5:22

GoogleCodeExporter commented 9 years ago
The argument to Arduino (or C, C++) trig functions is in Radians, not degrees.
Try pinfloat1 = sensorValye* (2.0/PI)/1023.0;

Original comment by wes...@gmail.com on 13 Nov 2012 at 3:31