Hi, I am new to writing codes.
I tried to do this code without importing library and it wont compile. Especially stuck on case default.
Any help is to be welcome.
const int buttonPin =8; //Forward / Reverse switch
int buttonState=0; //Pin goes to zero
int Pin0 = 3;
int Pin1 = 4;
int Pin2 = 5;
int Pin3 = 6;
int _step =0 ; //sets initial step to zero
boolean dir = true; // sets clockwise ++ or anticlockwise -- (DIR)
const byte stepperPin[4]={3,4,5,6};
void setup()
{
pinMode(stepperPin[4], OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState= digitalRead(buttonPin); // read the button pin == is condition
const byte stepSequence [4][4];
switch(_step){
case 0:
digitalWrite(stepperPin[], HIGH, HIGH, LOW, LOW);
break;
case 1:
digitalWrite(stepperPin[], LOW,HIGH,HIGH,LOW);
break;
case 2:
digitalWrite(stepperPin[], LOW,LOW,HIGH,HIGH);
break;
case 3:
digitalWrite(stepperPin[], HIGH,LOW,LOW,HIGH);
break;
default:
digitalWrite(stepperPin[], LOW,LOW,LOW,LOW);
break;
}
if(dir){
_step--;
}else{
_step++;
}
if(_step>3){
_step=0;
}
if(_step<0){
_step=3;
}
delay(5);
}