Home a stepper

Questions sur les codes officiels du core arpschuino
Questions about official codes from arpschuino core
Répondre
Adriaan
Messages : 1
Enregistré le : jeu. 2 déc. 2021 13:30

Home a stepper

Message par Adriaan »

Hallo,


I'd like to home a stepper motor at startup. How would I do this? using the 4 stepper code.


Thanks,
Adriaan
Jacques
Messages : 265
Enregistré le : dim. 31 oct. 2021 19:37

Re: Home a stepper

Message par Jacques »

Hello adriaan,
we already talk about that in this topic :https://forum.arpschuino.fr/viewtopic.php?t=17
Ok it's in french...
You need to use an end stop switch like this one for example : https://cdn03.plentymarkets.com/ioseuwg ... -23987.png
Attach it on a free I/O.

Code : Tout sélectionner

uint8_t zeroSwitch=Arp2;
initialise it in the setup :

Code : Tout sélectionner

pinMode(zeroSwitch, INPUT_PULLUP);
still in the setup, after initializing the stepper motor and before initializing DMX:

Code : Tout sélectionner

  stepper0.refresh(255, 30);//we define a direction of rotation (255, to go in the other direction : 0), and a speed (here 30 for a slow speed) 
  while (digitalRead(zeroSwitch))//as long as the limit switch is not pressed ((! zeroSwitch) reverses the behavior) 
  {
    stepper0.continuous();//turn !
  }
the stepper will turn until the switch is pressed, then it will stop at position 0;
Then it will listen to the DMX instructions.
Répondre