Skip to content

Commit 41ef611

Browse files
author
Rowan Easter
committed
Changed example to work on Arduino
1 parent 5a217d0 commit 41ef611

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/fitCurve/fitCurve.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ void setup(){
55
while(!Serial);
66
Serial.println("Starting");
77

8+
char buf[100];
89
int xpower = 3;
910
int order = 3;
10-
Serial.printf("Fitting curve of order %i to data of power %i...\n", order, xpower);
11+
snprintf(buf, 100, "Fitting curve of order %i to data of power %i...\n", order, xpower);
12+
Serial.print(buf);
1113

1214
double x[26];
1315
double t[26];
1416
for (int i = 0; i < sizeof(x)/sizeof(double); i++){
1517
t[i] = i;
16-
x[i] = power(i, xpower);
18+
x[i] = pow(i, xpower);
1719
}
1820

1921
double coeffs[order+1];
@@ -23,11 +25,11 @@ void setup(){
2325
uint8_t c = 'a';
2426
Serial.println("Coefficients are");
2527
for (int i = 0; i < sizeof(coeffs)/sizeof(double); i++){
26-
Serial.printf("%c=%f\t ",c++, coeffs[i]);
28+
snprintf(buf, 100, "%c=%f\t ",c++, coeffs[i]);
29+
Serial.print(buf);
2730
}
2831
}
2932
}
3033

3134
void loop(){
3235
}
33-

0 commit comments

Comments
 (0)