X-Git-Url: http://git.piffa.net/web?p=rover;a=blobdiff_plain;f=prototypes%2Fmotor%2Fmotor_pwm%2Fmotor_pwm.ino;fp=prototypes%2Fmotor%2Fmotor_pwm%2Fmotor_pwm.ino;h=718e5ba0736a6095135368069417bc37844508c3;hp=0000000000000000000000000000000000000000;hb=e5ee18ad49f4c9c25628e3925e51352083b18ced;hpb=ca67a73d0b0c3e654431b7675327a9c4bd88ba3e diff --git a/prototypes/motor/motor_pwm/motor_pwm.ino b/prototypes/motor/motor_pwm/motor_pwm.ino new file mode 100644 index 0000000..718e5ba --- /dev/null +++ b/prototypes/motor/motor_pwm/motor_pwm.ino @@ -0,0 +1,56 @@ +/* L298n motor +Aggiunta + +Pilotare 1 motore DC con un modulo l928n +Enable in PWM per settare velocita' massima + +- 1 motori DC +- L298n module +- Batteria > 6v + +*/ + + +// Configurazione con OUTPUT digitali +// motor one +const int enA = 6; +const int in1 = 7; +const int in2 = 8; +byte speedA = 255 +// motor two +const int enB = 5; +const int in3 = 4; +const int in4 = 3; +byte speedB = 0; + +void setup() { + pinMode(enA, OUTPUT); + pinMode(in1, OUTPUT); + pinMode(in2, OUTPUT); +// pinMode(enB, OUTPUT); +// pinMode(in3, OUTPUT); +// pinMode(in4, OUTPUT); +} + + +void loop() { +// Forward + digitalWrite(in1,LOW); + digitalWrite(in2,HIGH); + analogWrite(enA,speed); + delay(2000); + +// Stop + digitalWrite(enA,LOW); + delay(1000); + +// Backward + digitalWrite(in2,LOW); + digitalWrite(in1,HIGH); + analogWrite(enA,speed); + delay(2000); + +// Stop + digitalWrite(enA,LOW); + delay(1000); +}