Arduino uno R3 stepper motor control

Ken-

neksmerj:
Let's see your version of using the if/else statement, I've had my little go.

My code from yesterday looks like the below: two leds and a switch, as shown in the attached schematic.

//read a switch and if it's high,
//    put a led on. If it's low,
//    put a different led on instead.
//LEDs are on pins 5 and 6, with the anodes
//    to 5V and cathodes to the pins. So, the
//    leds come on when their i/o pins are low
//The switch is on pin 10 with pullup enabled,
//    so pin 10 is usually high but goes low
//    when the switch is pushed.
//Serial is enabled and the value of the pin
//    is shown in the monitor each time thru loop()

byte ledOne=5; // a byte is the smallest type that can store a number
byte ledTwo=6;
byte mySwitch = 10;
bool mySwitchVal; // it can only be on or off so bool is cool


void setup() {
 Serial.begin(9600);
 pinMode(ledOne, OUTPUT);
 pinMode(ledTwo, OUTPUT);
 pinMode(mySwitch, INPUT_PULLUP);

}

void loop() {
mySwitchVal= digitalRead(mySwitch);
Serial.println(mySwitchVal);

if (mySwitchVal == 1)  // note the == not just a =
{
 digitalWrite(ledOne, HIGH);
 digitalWrite(ledTwo, LOW);
}
else // if not 1, it must be 0
{
 digitalWrite(ledOne, LOW);
 digitalWrite(ledTwo, HIGH);
}

}

twoledsswitch.PNG