From: Andrea Manni Date: Wed, 5 Apr 2017 10:51:46 +0000 (+0200) Subject: Sistemati gli include della lib Servo.h X-Git-Url: http://git.piffa.net/web?a=commitdiff_plain;h=a3f175c8785d2505c3da9d3e3386952ebc2cc018;p=rover Sistemati gli include della lib Servo.h --- diff --git a/libraries/rover/rover.cpp b/libraries/rover/rover.cpp index f284162..d95fe06 100644 --- a/libraries/rover/rover.cpp +++ b/libraries/rover/rover.cpp @@ -24,8 +24,17 @@ const int enB = 5; const int in3 = 4; const int in4 = 3; byte speedB = 255; -// Funzioni +// Servo vars +int pos = 0; // variable to store the servo position +const byte servoPIN =9 ; +const byte middle = 90; // Centratura servo +const int spausa = 30; // Pausa movimenti servo +Servo myservo; // Non c'e' bisogno di extern se e' dichiarato in questo scope + +//////////////////////// +// Funzioni: +// void abilita() { // Abilita i PINs come OUTPUTS pinMode(enA, OUTPUT); @@ -34,6 +43,10 @@ void abilita() { pinMode(enB, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT); + + + pinMode(servoPIN, OUTPUT); + myservo.attach(servoPIN); } diff --git a/libraries/rover/rover.h b/libraries/rover/rover.h index a4ad42b..ce72cdb 100644 --- a/libraries/rover/rover.h +++ b/libraries/rover/rover.h @@ -9,6 +9,7 @@ Licenza: GPLv3 */ #include "Arduino.h" +#include "Servo.h" #ifndef rover_h #define rover_h diff --git a/prototypes/servo/rotation_lib/rotation_lib.ino b/prototypes/servo/rotation_lib/rotation_lib.ino index 130d38d..763e8f2 100644 --- a/prototypes/servo/rotation_lib/rotation_lib.ino +++ b/prototypes/servo/rotation_lib/rotation_lib.ino @@ -21,16 +21,10 @@ #include -#include +#include "Servo.h" -Servo myservo; // create servo object to control a servo // a maximum of eight servo objects can be created -// Servo vars -int pos = 0; // variable to store the servo position -const byte servo =9 ; -const byte middle = 90; // Centratura servo -const int spausa = 30; // Pausa movimenti servo void setup() {