Motor shield using stepper hanging on begin() call

I believe this is the best topic for what I am seeking help on. I have been using Adafruit projects for a fair time,years… I am experienced in electronics and programming. I am working on a project to make an IR waxer for skiis/snow boards. I have an Arduino Uno, a motor shield rev2, a LCD 16x2 display with an ic2 backpack, a potentiometer, and a button. I have tested each separately before I began putting the final project together, I am in testing phase for programming/hardware as a solution. For some reason I cannot get the stepper to get past the begin() function call… I do get a display print. For the code below I cannot get to line 75( last line of code ). I do get the serial print on line 70. Any ideas would be helpful. I have checked ic2 addressing, have three devices using 0x60, 70, 72.

Thanks for ideas… David

#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include <Adafruit_PWMServoDriver.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

Adafruit_MotorShield AFMS = Adafruit_MotorShield();

Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 1);

#define DEBOUNCE 10 // button debouncer, how many ms to debounce, 5+ ms is usually plenty

// here is where we define the buttons that we’ll use. button “1” is the first, button “6” is the 6th, etc
byte buttons = {3}; // the analog 0-5 pins are also known as 14-19

// This handy macro lets us determine how big the array up above is, by checking the size
#define NUMBUTTONS sizeof(buttons)

// we will track if a button is just pressed, just released, or ‘currently pressed’
byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];
byte hBval = HIGH; // new variable for home button value HIGH/LOW

int length_travel = 0;
float steps_travel = 0;
int motorSpeed = 0;
#define stepper_travel 159.59 //Distance travelled for one rotation of stepper, based on size of waxer wheel
#define stepper_steps 200 //Steps for a single rotation nema 17 stepper

//button analog pin 3
//home limit switch analog pin 4
//home limit switch analog pin 5
int ledPin = 13; //visible light on case to indicate operation
int heatPin = 12; //infrared element control

void setup() {
// put your setup code here, to run once:

Serial.begin(9600); // open the serial port at 9600 bps:

// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);

// initialize the Infrared pin as an output
pinMode(heatPin, OUTPUT);

//start up LCD Display
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Start up…”);

// turn LED off:
digitalWrite(ledPin, LOW);

// turn heat off:
digitalWrite(heatPin, LOW);

byte i; //loop counter

Serial.println(“for loop”);

// Make input & enable pull-up resistors on switch pins
for (i = 3; i < (NUMBUTTONS + 4); i++) {
pinMode(buttons*, INPUT_PULLUP);*

  • }*
  • Serial.println(“AFMS”);*
  • //Set stepper*
  • AFMS.begin();*
  • Serial.println(“setspeed”);*
  • myMotor->setSpeed(0);*
  • Serial.println(“Home Stepper”);*

I see the setup() but I don't see the loop() part of your program. where is it? Paul

I didn't copy that part, the loop() because it never makes it paste the last line I copied. So loop never runs... I am using print statements to debug steps so I know where issue was... The program never gets to the loop print at the last line I posted.

drosi: I didn't copy that part, the loop() because it never makes it paste the last line I copied. So loop never runs... I am using print statements to debug steps so I know where issue was... The program never gets to the loop print at the last line I posted.

You are only guessing about that. If I can't see past that last line, how can I help? please post you code properly and no italics. Paul

Okay,

Here is code through the loop. Only thing missing would be functions I wrote that are called.

#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include <Adafruit_PWMServoDriver.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

Adafruit_MotorShield AFMS = Adafruit_MotorShield();

Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 1);

#define DEBOUNCE 10 // button debouncer, how many ms to debounce, 5+ ms is usually plenty

// here is where we define the buttons that we’ll use. button “1” is the first, button “6” is the 6th, etc
byte buttons = {3}; // the analog 0-5 pins are also known as 14-19

// This handy macro lets us determine how big the array up above is, by checking the size
#define NUMBUTTONS sizeof(buttons)

// we will track if a button is just pressed, just released, or ‘currently pressed’
byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];
byte hBval = HIGH; // new variable for home button value HIGH/LOW

int length_travel = 0;
float steps_travel = 0;
int motorSpeed = 0;
#define stepper_travel 159.59 //Distance travelled for one rotation of stepper, based on size of waxer wheel
#define stepper_steps 200 //Steps for a single rotation nema 17 stepper

//button analog pin 2
//home limit switch analog pin 3
//home limit switch analog pin 4
int ledPin = 13; //visible light on case to indicate operation
int heatPin = 12; //infrared element control

void setup() {
// put your setup code here, to run once:

Serial.begin(9600); // open the serial port at 9600 bps:

// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);

// initialize the Infrared pin as an output
pinMode(heatPin, OUTPUT);

//start up LCD Display
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(“Start up…”);

// turn LED off:
digitalWrite(ledPin, LOW);

// turn heat off:
digitalWrite(heatPin, LOW);

byte i; //loop counter

Serial.println(“for loop”);

// Make input & enable pull-up resistors on switch pins
for (i = 3; i < (NUMBUTTONS + 4); i++) {
pinMode(buttons*, INPUT_PULLUP);*

  • }*
  • Serial.println(“AFMS”);*
  • //Set stepper*
  • AFMS.begin();*
  • Serial.println(“setspeed”);*
  • myMotor->setSpeed(0);*
  • Serial.println(“Home Stepper”);*
  • //Reset gantry to start*
  • stepperHome(); //function call, see below*
  • myMotor->release(); //power down power to stepper*
    }//End Setup *************************************************************************************************
    void loop() {
  • Serial.println(“Loop”);*
  • //put Display message to press button to start*
  • lcd.clear();*
  • lcd.setCursor(0, 0);*
  • lcd.print(“Press Start Button to”);*
  • lcd.setCursor(1, 1);*
  • lcd.print(“Begin Wax Process”);*
  • check_switches(); // when we check the switches we’ll get the current state*
  • //If button pressed start waxer sequence*
  • if ( justpressed[0] == 1) {*
  • justpressed[0] = 0; //Reset button state*
  • start_waxing(); //start waxing sequence, see function below*
  • }*
    }//End loop

There is something stray in your code that is causing the forum software to begin showing italics in the listing. Can you find what that invisible something is? Might be the cause of the problem. Paul