1 pièce(s) jointe(s)
Aide a la programmation moteur PAS a PAS avec driver + Arduino
Bonjour,
Je voudrais bien avoir de l'aide sur la programmation d'un moteur pas a pas avec driver sur arduino mega.
Mon souci c'est d'ajouter bouton marche et arrêt sur mon programme telle qu'il est ;
output (2) marche
output (3) Arrêt
Quelque chose comme sa !
Mon moteur démarre immédiatement après alimentation chose que sa dérange
Merci de bien vouloir m'aidé a se sujet.
Cordialement
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| /*
Stepper Motor Test
stepper-test01.ino
Uses MA860H or similar Stepper Driver Unit
Has speed control & reverse switch
DroneBot Workshop 2019
https://dronebotworkshop.com
*/
// Defin pins
int reverseSwitch = 2; // Push button for reverse
int driverPUL = 7; // PUL- pin
int driverDIR = 6; // DIR- pin
int spd = A0; // Potentiometer
// Variables
int pd = 500; // Pulse Delay period
boolean setdir = LOW; // Set Direction
// Interrupt Handler
void revmotor (){
setdir = !setdir;
}
void setup() {
pinMode (driverPUL, OUTPUT);
pinMode (driverDIR, OUTPUT);
attachInterrupt(digitalPinToInterrupt(reverseSwitch), revmotor, FALLING);
}
void loop() {
pd = map((analogRead(spd)),0,1023,2000,50);
digitalWrite(driverDIR,setdir);
digitalWrite(driverPUL,HIGH);
delayMicroseconds(pd);
digitalWrite(driverPUL,LOW);
delayMicroseconds(pd);
} |
Merci.Pièce jointe 589344