Projet

Général

Profil

UtilisationMoteur » Historique » Révision 4

Révision 3 (Alexandre FIALE, 17/03/2016 15:34) → Révision 4/10 (Alexandre FIALE, 17/03/2016 15:36)

UtilisationMoteur
=================

Sketch
------

Voici le sketch utilisé pour l'atelier :

int motor1P1 = 2;
int motor1P2 = 3;
int motor1PWM = 9;
int delai = 2000;
void setup() {
Serial.begin(9600);
pinMode(motor1P1, OUTPUT);
pinMode(motor1P2, OUTPUT);
pinMode(motor1PWM, OUTPUT);
}

void loop() {
delay(delai);
forward();
delay(delai);
backward();
delay(delai);
stopMotor();
delay(delai);
}

void forward() {
int i =0;
digitalWrite(motor1P1, HIGH);
digitalWrite(motor1P2, LOW);

for(i=0; i<255; i++) {
analogWrite(motor1PWM, i);
Serial.print('speed');
Serial.println(i);
}
}

void backward() {
int i =0;
digitalWrite(motor1P1, LOW);
digitalWrite(motor1P2, HIGH);

for(i=0; i<255; i++) {
analogWrite(motor1PWM, i);
}
}

void stopMotor() {
digitalWrite(motor1P1, LOW);
digitalWrite(motor1P2, LOW);
}

Schéma de cablage
------

![schéma](http://redmine.acolab.fr/attachments/download/122/riorand-L298N%20copie.jpg) ![schéma](riorand-L298N copie.jpg )