Go Down

Topic: Due and pin13 (Read 470 times) previous topic - next topic

ribbonman

I just bought a Due and seem to be having trouble, when powering up the board pin13 goes HIGH and the program won't run until I press the reset button on the board.

I ran the same code on a Mega and had no problems but there must be something different about the Due so I thought I would ask in case it was something simple that I haven't read about.

Once I hit the reset it will act properly( I start the program over and over with the press of a button). I have nothing connected to pin13

Hardware is
Due
Littlefuse 55100-3H Hall sensor
Gecko 203 stepper Driver
button

Code: [Select]

#include <AccelStepper.h>

AccelStepper stapler(AccelStepper::DRIVER, 3, 4);

//VALUES FOR BUTTON
const int button = 2;            // pin button is on
int val = LOW;                     // current button state
int old_val = LOW;
int buttonstate = LOW;
unsigned long previousMillis = LOW;


//VALUES FOR TURNING STAPLER 4 TURNS(using stapler hall Sensor)
int staplercounter = 0;
int staplercurrentState = 0;
int staplerpreviousState = 0;
int staplerSensor = 47;

void setup() {

  pinMode(button, INPUT_PULLUP);
  Serial.begin(9600);

}

void loop() {

  readButton();
  staplefour();
}

void readButton() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= 100) {
    val = digitalRead(button);
    if ((val == LOW) && (old_val == HIGH)) {
      buttonstate = HIGH;
    }
    previousMillis = currentMillis;
    old_val = val;
    Serial.println(buttonstate);
  }
}

void staplefour() {

  stapler.setMaxSpeed(10000.0);

  staplercurrentState = digitalRead(staplerSensor);   //set state for movement
  if (buttonstate == HIGH && staplercounter <= 4) {
    stapler.setSpeed(-5000);
    staplercurrentState = digitalRead(staplerSensor);   //keep checking till it hits 4
    if (staplercounter >= 4) {
      stapler.setSpeed(0);                      //turn motor off
    }
  }
  if (staplercurrentState != staplerpreviousState) {    //check the count and add 1
    if (staplercurrentState == 1) {
      staplercounter = staplercounter + 1;
      Serial.println(staplercounter);
    }
  }
  staplerpreviousState = staplercurrentState;
  if (staplercounter >= 4) {
    buttonstate = LOW;                   //reset button
    staplercounter = 0;                    //reset counter for next button push
    staplercurrentState = 0;               //reset state for next button push
  }
  stapler.runSpeed();
}

srnet

Try a google search on;

'problems with reset on arduino due'

For some hints.

ribbonman

Try a google search on;

'problems with reset on arduino due'

For some hints.
Hi @srnet,
I tried that but I don't think that is my problem as I have an R3 version , the board powers up just fine but it leaves the pin13 LED on HIGH and when I hit the reset it the LED goes LOW and program will run.

I loaded the blink sketch from the Arduino IDE and the problem didn't occur so I must have some problem within my code, I have removed all connections to the board to rule that out and will add the code in line by line and see where the offending line is. Gonna take a while I think.

Go Up