Jump to content
Sign in to follow this  
vinodstanur

sine function not accepting variable argument

Recommended Posts

Hi,

 I am using arm-none-eabi-xxx for stellaris launchpad develpment. I tried the math library but sin, cos functions are not returning any thing if I pass variable arguments but it is working with constant arguments.

 

Any idea?

Share this post


Link to post
Share on other sites

I assume that you are using Energia to compile and thus use the compiler supplied with Energia? If you are using a different compiler then you might want to try the general forum.

The Sketch below works for me.

 

void setup() {                
  Serial.begin(115200);
}

float deg2rad(float deg)
{
  return (deg * PI)/180.0f;
}

float deg = 0;
float s;

void loop() {
  Serial.print("sin(");
  Serial.print(deg);
  Serial.print(") = ");
  Serial.println(sin(deg2rad(deg)), DEC);
  
  deg += 1;
  if(deg > 360)
    deg = 0;  

  delay(100);
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×