Hallo!
Ich habe ein Problem mit einer While Schleife in meinem Programm.
Ich möchte einen Schrittmotor eine bestimmte Anzahl an Schritten laufen
lassen (100 Schritte).
Mein Programm:
1 | #include <Stepper.h>
|
2 | const int stepsPerRevolution = 2048; // here go the 2048 steps
|
3 | // for your motor
|
4 |
|
5 | // initialize the stepper library on pins 8 through 11 -> IN1, IN2, IN3, IN4
|
6 | // as shown above, we need to exchange wire 2&3, which we do in the constructor
|
7 | Stepper myStepper(stepsPerRevolution, 2, 3, 4, 5);
|
8 | int stepCount = 0; // number of steps the motor has taken
|
9 |
|
10 | void setup()
|
11 |
|
12 | {
|
13 |
|
14 | // initialize the serial port:
|
15 | Serial.begin(9600);
|
16 |
|
17 | }
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | void loop()
|
23 |
|
24 | {
|
25 |
|
26 | while (stepCount < 100);
|
27 | {
|
28 | myStepper.step(1);
|
29 | Serial.print("steps: ");
|
30 | Serial.println(stepCount);
|
31 | stepCount++;}
|
32 |
|
33 |
|
34 |
|
35 | }
|
Leider funktioniert das Programm nicht. Es passiert nichts.
Ersetze ich das while durch ein IF läuft der Motor dauerhaft, auch wenn
das while auskommentiert wird läuft er ganz normal.
Ich bin schon am verzweifeln.
Wisst ihr woran das liegen könnte?
Danke! :)