Altering DC Motor Shield Program

You toke one step backwards.
Setup is run once at start up. Then loop() is the inly code running iver snd over again.
You need both set spead and release in the loop between button read and delay.
Why did You move good code into setup?

Railroader:
You toke one step backwards.
Setup is run once at start up. Then loop() is the inly code running iver snd over again.
You need both set spead and release in the loop between button read and delay.
Why did You move good code into setup?

The only thing added back into the set up was the RELEASE part....wanted to at least try it. Per your suggestion, I just took it back out and ran the program again. No change.

In the original DC Motor Test, they had the speed, forward and release in the set up. Do I need to keep these in the set up? Do I take them out of set up and put them within my if..else statements due to the pushbutton input?

I'm really tying to understand. I'll keep trying new things but it seems that I just don't know enough about IF..ELSE statements as well as how to run this library.

I got some help from some of the folks on these forums to get this little pushbutton program working and I was trying to alter the motorshield program to run the same way. This little circuit worked! I pushed the button and the light stayed on for 5 seconds and then shut off again until I hit the button again.

void loop() {
  if (digitalRead(11) == HIGH) {
    delay(10);
    myMotor->run(FORWARD);
    delay(5000);
  }
  else {
    delay(10);
    myMotor->setSpeed(0);
    myMotor->run(RELEASE);
  }
}

Update:

I got it to work as intended using the code below. I push the button and the motor runs at the given speed for 5 seconds and then shuts off.

I removed the setspeed and direction from the set up. I changed the button input to LOW. I tried the code first with only removing the setspeed and direction from the set up and I noticed that the motor shut off after I help the button for 5 seconds.

All in all, im still somewhat confused about a few things but I know I can figure it out. Huge thanks to railroader...karma added!

#include <Wire.h>
#include <Adafruit_MotorShield.h>
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
void setup() {
  Serial.begin(9600);
  AFMS.begin();
  pinMode(11, INPUT_PULLUP);
}
void loop() {
  if (digitalRead(11) == LOW) {
    myMotor->setSpeed(150);
    myMotor->run(FORWARD);
    delay(5000);
  }
  else {
    myMotor->setSpeed(0);
    myMotor->run(RELEASE);
  }
}

Nice!
I am surpriced that release is not needed for starting, only the speed 0 stopping.
Never mind, now You have a base to work from.
Thanks!

Nice!
I am surpriced that release is not needed for starting, only the speed 0 stopping.
Never mind, now You have a base to work from.
Thanks!