--- /dev/null
+/* L298n motor
+Aggiunta
+
+Guida 2WD composta da 2 motori
+
+- 2 motori DC
+- L298n module
+- Batteria > 6v
+
+*/
+
+#include <rover.h>
+
+void setup() {
+ abilita();
+}
+
+
+void loop() {
+// Avanti
+ avanti();
+ delay(2000);
+// Stop
+ stop();
+ delay(1000);
+
+// TurnSX
+ turnSX();
+ delay(1000);
+
+// Avanti
+ avanti();
+ delay(2000);
+// Stop
+ stop();
+ delay(1000);
+
+
+// TurnDX
+ turnDX();
+ delay(1000);
+
+// Stop
+ stop();
+ delay(1000);
+}
+
+// Functions
+void avanti() {
+ // Drive ahead: funzione composita
+ forwardA() ;
+ forwardB() ;
+}
+
+void indietro() {
+ // Drive backward: funzione composita
+ backwardA();
+ backwardB();
+}
+
+void turnDX() {
+ // Gira a DX
+ forwardB() ;
+ backwardA();
+}
+
+void turnSX() {
+ // Gira a DX
+ forwardA() ;
+ backwardB();
+}
+
+void stop() {
+ stopA();
+ stopB();
+}
+++ /dev/null
-/* L298n motors
-Aggiunta
-
-Pilotare 1 motore DC con un modulo l928n
-
-- 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 = 0;
-// 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);
- digitalWrite(enA,HIGH);
- delay(2000);
-
-// Stop
- digitalWrite(enA,LOW);
- delay(1000);
-
-// Backward
- digitalWrite(in2,LOW);
- digitalWrite(in1,HIGH);
- digitalWrite(enA,HIGH);
- delay(2000);
-
-// Stop
- digitalWrite(enA,LOW);
- delay(1000);
-}
--- /dev/null
+/* L298n motor
+Aggiunta
+
+Pilotare 2 motore DC con un modulo l928n
+Enable in PWM per settare velocita' massima
+
+- 2 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 = 255;
+
+void setup() {
+ pinMode(enA, OUTPUT);
+ pinMode(in1, OUTPUT);
+ pinMode(in2, OUTPUT);
+ pinMode(enB, OUTPUT);
+ pinMode(in3, OUTPUT);
+ pinMode(in4, OUTPUT);
+}
+
+
+void loop() {
+// Forward
+ forwardA();
+ forwardB();
+ delay(2000);
+
+// Stop
+ stopA();
+ stopB();
+ delay(1000);
+
+// Backward
+ backwardA();
+ backwardB();
+ delay(2000);
+
+// Stop
+ stopA();
+ stopB();
+ delay(1000);
+}
+
+// Functions
+
+// MotorB
+void forwardA() {
+ // Avanzamento motore
+ digitalWrite(in1,LOW);
+ digitalWrite(in2,HIGH);
+ analogWrite(enA,speedA);
+}
+
+void backwardA() {
+ // Reverse motore
+ digitalWrite(in2,LOW);
+ digitalWrite(in1,HIGH);
+ analogWrite(enA,speedA);
+}
+
+void stopA() {
+ // Stop
+ digitalWrite(enA,LOW);
+}
+
+// MotorB
+void forwardB() {
+ // Avanzamento motore
+ digitalWrite(in3,LOW);
+ digitalWrite(in4,HIGH);
+ analogWrite(enB,speedB);
+}
+
+void backwardB() {
+ // Reverse motore
+ digitalWrite(in4,LOW);
+ digitalWrite(in3,HIGH);
+ analogWrite(enB,speedB);
+}
+
+void stopB() {
+ // Stop
+ digitalWrite(enB,LOW);
+}
--- /dev/null
+/* 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);
+}
--- /dev/null
+/* L298n motor
+Aggiunta
+
+Pilotare 2 motore DC con un modulo l928n
+Enable in PWM per settare velocita' massima
+
+- 2 motori DC
+- L298n module
+- Batteria > 6v
+
+*/
+#include <rover.h>
+
+
+void setup() {
+ abilita();
+}
+
+
+void loop() {
+// Forward
+ forwardA();
+ forwardB();
+ delay(2000);
+
+// Stop
+ stopA();
+ stopB();
+ delay(1000);
+
+// Backward
+ backwardA();
+ backwardB();
+ delay(2000);
+
+// Stop
+ stopA();
+ stopB();
+ delay(1000);
+}
--- /dev/null
+/* L298n motor
+Aggiunta
+
+Pilotare 1 motore DC con un modulo l928n
+
+- 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 = 0;
+// 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);
+ digitalWrite(enA,HIGH);
+ delay(2000);
+
+// Stop
+ digitalWrite(enA,LOW);
+ delay(1000);
+
+// Backward
+ digitalWrite(in2,LOW);
+ digitalWrite(in1,HIGH);
+ digitalWrite(enA,HIGH);
+ delay(2000);
+
+// Stop
+ digitalWrite(enA,LOW);
+ delay(1000);
+}