Break?

:o

I have typed a program for stepper motor, but the break doesn’t work. Why does this happen?

int bluePin = 2;
int pinkPin = 3;
int yellowPin = 4;
int orangePin = 5;

int currentStep = 0;

void setup(){

pinMode(bluePin,OUTPUT);
pinMode(pinkPin,OUTPUT);
pinMode(yellowPin,OUTPUT);
pinMode(orangePin,OUTPUT);

digitalWrite(bluePin,LOW);
digitalWrite(pinkPin,LOW);
digitalWrite(yellowPin,LOW);
digitalWrite(orangePin,LOW);
}

void loop() {

switch(currentStep)
case 0:
digitalWrite(bluePin,HIGH);
digitalWrite(pinkPin,LOW);
digitalWrite(yellowPin,LOW);
digitalWrite(orangePin,LOW);
break;
case 1:
digitalWrite(bluePin,LOW);
digitalWrite(pinkPin,HIGH);
digitalWrite(yellowPin,LOW);
digitalWrite(orangePin,LOW);
break;
case 2:
digitalWrite(bluePin,LOW);
digitalWrite(pinkPin,LOW);
digitalWrite(yellowPin,HIGH);
digitalWrite(orangePin,LOW);
break;
case 3:
digitalWrite(bluePin,LOW);
digitalWrite(pinkPin,LOW);
digitalWrite(yellowPin,LOW);
digitalWrite(orangePin,HIGH);
break;

}

currentStep = (++currentStep < 4) ? currentStep : 0;

delay(10);
}

Error Message:

C:\Users\HJIS\Documents\Arduino\Realsteppermotor\Realsteppermotor.ino: In function ‘void loop()’:

Realsteppermotor:29: error: break statement not within loop or switch

break;

^

Realsteppermotor:30: error: case label ‘1’ not within a switch statement

case 1:

^

Realsteppermotor:35: error: break statement not within loop or switch

break;

^

Realsteppermotor:36: error: case label ‘2’ not within a switch statement

case 2:

^

Realsteppermotor:41: error: break statement not within loop or switch

break;

^

Realsteppermotor:42: error: case label ‘3’ not within a switch statement

case 3:

^

Realsteppermotor:47: error: break statement not within loop or switch

break;

^

C:\Users\HJIS\Documents\Arduino\Realsteppermotor\Realsteppermotor.ino: At global scope:

Realsteppermotor:51: error: ‘currentStep’ does not name a type

currentStep = (++currentStep < 4) ? currentStep : 0;

^

Realsteppermotor:53: error: expected constructor, destructor, or type conversion before ‘(’ token

delay(10);

^

Realsteppermotor:54: error: expected declaration before ‘}’ token

}

^

exit status 1
break statement not within loop or switch

Invalid library found in \192.168.1.5\StudentsWork\00-Grade-10\Hami El Penguino\2016-2017\Hami’s Arduino\arduino-1.8.1\libraries\Realsteppermotor: \192.168.1.5\StudentsWork\00-Grade-10\Hami El Penguino\2016-2017\Hami’s Arduino\arduino-1.8.1\libraries\Realsteppermotor
Invalid library found in \192.168.1.5\StudentsWork\00-Grade-10\Hami El Penguino\2016-2017\Hami’s Arduino\arduino-1.8.1\libraries\Realsteppermotor: \192.168.1.5\StudentsWork\00-Grade-10\Hami El Penguino\2016-2017\Hami’s Arduino\arduino-1.8.1\libraries\Realsteppermotor

Your switch is missing braces.
Your whole post is missing code tags.

What do you me by braces?

Curly brackets.

{ needs a friend }

Specifically, here:

switch(currentStep) {
case 0:

It looks like you already have the close-brace at the end of your cases...