Outils pour utilisateurs

Outils du site


wiki:projets:lien_code_3_moteurs
#include <Stepper.h>
#include <AFMotor.h>
 
int enA  = 3;  
int enB  = 11;  
int dirA = 12;  
int dirB = 13;  
 
 
const int stepsPerRevolution = 400;  
 
Stepper myStepper(stepsPerRevolution, dirA, dirB);            
AF_Stepper motor1(400,1);
AF_Stepper motor2(400,2);
 
 
void forwardstep1()
{
    motor1.onestep(FORWARD,SINGLE);
}
void backwardstep1()
 
{
    motor1.onestep(BACKWARD,SINGLE);
}
 
void forwardstep2()
{
    motor2.onestep(FORWARD,SINGLE);
}
void backwardstep2()
{
    motor2.onestep(BACKWARD,SINGLE);
}
 
void setup() {
 
  myStepper.setSpeed(60);
 
 
  pinMode(enA, OUTPUT);
  digitalWrite (enA, HIGH);
 
  pinMode(enB, OUTPUT);
  digitalWrite (enB, HIGH);  
 
  motor1.setSpeed(25);
  motor2.setSpeed(35);
 
}
 
void loop() {
 
 motor1.step(100,FORWARD,SINGLE);
 delay(1000);
 
 motor2.step(3200,BACKWARD,SINGLE);    
 delay(1000);
 motor2.step(3200,FORWARD,SINGLE);      
 delay(1000);
 
 
 
 
  myStepper.step(stepsPerRevolution*20);
  delay(2000);
 
  myStepper.step(-stepsPerRevolution*10);
  delay(2000);  
 
}
wiki/projets/lien_code_3_moteurs.txt · Dernière modification: 2017/03/20 14:14 de CASANOVA Oceane