#define dEBUG
-//////////////////
+// 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;
// Funzioni
+void abilita() {
+// Abilita i PINs come OUTPUTS
+ pinMode(enA, OUTPUT);
+ pinMode(in1, OUTPUT);
+ pinMode(in2, OUTPUT);
+ pinMode(enB, OUTPUT);
+ pinMode(in3, OUTPUT);
+ pinMode(in4, OUTPUT);
+}
+
+
+// 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);
+}
#ifndef rover_h
#define rover_h
-//////////////////////
-// OBJ
-
-
-class engine {
-// Gestione di un singolo motore
-private:
- byte enablePIN1;
- byte enablePIN2;
- byte min; // Minimo per partire
- byte val; // 8bit PWM
-
-public:
- Engine (byte PIN1, byte PIN2, byte PINPWM);
- void Forward ();
- void Backward ();
- void SetSpeed (); // imposta un valore preciso per il PWM
-
-}
-
-class motors {
-// classe composta da due engines
-// Composition is better than inheritance here
-
-public:
- motors (engine enginesx, engine enginedx) {
- void Forward ();
- void Backward ();
- void TurnLeft ();
- void TurnRight ();
- void TurnU ();
-}
-}
-//////////////////////
+// Global vars
+
+
// Funzioni
+void abilita() ;
+void forwardA() ;
+void backwardA() ;
+void stopA() ;
+void forwardB() ;
+void backwardB() ;
+void stopB() ;
#endif