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=00c1fa9df30a7c1b88d0c40412fd3812dd06bff3;p=rover Sistemati gli include della lib Servo.h --- diff --git a/libraries/rover/keywords.txt b/libraries/rover/keywords.txt index 591e203..d698c40 100644 --- a/libraries/rover/keywords.txt +++ b/libraries/rover/keywords.txt @@ -1 +1,25 @@ -toggleRead KEYWORD2 +toggleRead KEYWORD2 +abilita KEYWORD2 +forwardA KEYWORD2 +forwardA KEYWORD2 +backwar KEYWORD2 +backwardA KEYWORD2 +stopA KEYWORD2 +forwardB KEYWORD2 +forwardB KEYWORD2 +backwardB KEYWORD2 +backwardB KEYWORD2 +stopB KEYWORD2 + +turnDX KEYWORD2 +turnSX KEYWORD2 +turnMiddle KEYWORD2 +myservo KEYWORD1 + +car KEYWORD1 +avanti KEYWORD2 +indietro KEYWORD2 +stop KEYWORD2 +giraSX KEYWORD2 +giraDX KEYWORD2 +setSpeed KEYWORD2 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() {