本帖最后由 凯风自北来 于 2015-7-8 10:17 编辑
之前编程的时候几个量都是整型的,后来为精确起见改成浮点型,但是就报错了,请大神帮忙看下问题在哪里
arduino IDE提示
_1.ino: In function 'void setup()':
_1:18: error: invalid operands of types 'float' and 'int' to binary 'operator^'
_1:20: error: invalid operands of types 'float' and 'int' to binary 'operator^'
invalid operands of types 'float' and 'int' to binary 'operator^'
- #include <AccelStepper.h>
- AccelStepper stepper1(1, 9, 8);
- AccelStepper stepper2(1, 7, 6);
- float flowrate1=17;
- float diameter1=8.24;
- int pitch1=1;
- float area1;
- float velocity1;
- float flowrate2=17;
- float diameter2=8.24;
- int pitch2=1;
- float area2;
- float velocity2;
- int pos1 = 3600;
- int pos2 = 5678;
- void setup()
- {
- area1=3.14*((diameter1/2)^2);
- velocity1=(flowrate1/area1)*80/3;
- area2=3.14*((diameter2/2)^2);
- velocity2=(flowrate2/area2)*80/3;
- stepper1.setMaxSpeed(velocity1);
- stepper1.setAcceleration(1000);
- stepper2.setMaxSpeed(velocity2);
- stepper2.setAcceleration(1000);}
- void loop()
- {
- if (stepper1.distanceToGo() == 0)
- {
- pos1 = -pos1;
- stepper1.moveTo(pos1);
- }
- if (stepper2.distanceToGo() == 0)
- {
- pos2 = -pos2;
- stepper2.moveTo(pos2);
- }
- stepper1.run();
- stepper2.run();
- }
-
复制代码 |