Hey can somebody please tell me where I have done the dummy mistake and why it doesn’t work?
It alway gives out zeros for both x and y in the serial print.
int i;
int x;
int y;
void setup() {
Serial.begin(9600);
}
void loop() {
for (i=0; i < 2*PI; i++);
x = sin(i);
y = cos(i);
Serial.print("x = ");
Serial.print(y);
Serial.print("\t y = ");
Serial.println(y);
delay(20);
}
// Trig Test
int d; // degrees
float r; // radians
float s;
float c;
void setup() {
Serial.begin(9600);
}
void loop() {
for (d = 0; d <= 360; d += 10) { // step by 10 to cut down the clutter and see the functions
r = d * PI / 180 ; //convert degrees to rad for Arduino trig funtions
s = sin(r);
c = cos(r);
Serial.print(" deg = ");
Serial.print(d);
Serial.print("\t sin = ");
Serial.print(s, 4); // ,4 is 4 decimal places
Serial.print("\t cos= ");
Serial.println(c, 4);
delay(100); // lets you see it work...
}
Serial.println(); // throws a blank line at the end
Serial.end(); // kills output after 1 cycle
}