Go Down

Topic: Problema con libreria (Read 622 times) previous topic - next topic

-mike-

Salve a tutti,
sto scrivendo una libreria per un mio progetto personale con arduino ma quando provo ad includerla mi escono vari errori di cui non riesco a capire il motivo:

Code: [Select]

Arduino:1.6.9 (Windows 7), Scheda:"Arduino/Genuino Uno"

In file included from C:\Users\Utente168\Desktop\test\test.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:16:5: error: 'l_shoulder_pitch' does not name a type

     l_shoulder_pitch.attach(A0);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:17:5: error: 'l_thigh_yaw' does not name a type

     l_thigh_yaw.attach(A5);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:18:5: error: 'l_shoulder_roll' does not name a type

     l_shoulder_roll.attach(2);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:19:5: error: 'l_elbow_roll' does not name a type

     l_elbow_roll.attach(13);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:20:5: error: 'l_thigh_roll' does not name a type

     l_thigh_roll.attach(3);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:21:5: error: 'l_thigh_pitch' does not name a type

     l_thigh_pitch.attach(A4);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:22:5: error: 'l_knee_pitch' does not name a type

     l_knee_pitch.attach(A3);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:23:5: error: 'l_foot_pitch' does not name a type

     l_foot_pitch.attach(A1);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:24:5: error: 'l_foot_roll' does not name a type

     l_foot_roll.attach(A2);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:25:5: error: 'r_shoulder_pitch' does not name a type

     r_shoulder_pitch.attach(11);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:26:5: error: 'r_thigh_yaw' does not name a type

     r_thigh_yaw.attach(6);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:27:5: error: 'r_shoulder_roll' does not name a type

     r_shoulder_roll.attach(4);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:28:5: error: 'r_elbow_roll' does not name a type

     r_elbow_roll.attach(12);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:29:5: error: 'r_thigh_roll' does not name a type

     r_thigh_roll.attach(5);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:30:5: error: 'r_thigh_pitch' does not name a type

     r_thigh_pitch.attach(7);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:31:5: error: 'r_knee_pitch' does not name a type

     r_knee_pitch.attach(8);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:32:5: error: 'r_foot_pitch' does not name a type

     r_foot_pitch.attach(10);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:33:5: error: 'r_foot_roll' does not name a type

     r_foot_roll.attach(9);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:13: error: 'eyes' is not a type

     pinMode(eyes, OUTPUT);

             ^

In file included from sketch\test.ino.cpp:1:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected identifier before numeric constant

 #define OUTPUT 0x1

                ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:19: note: in expansion of macro 'OUTPUT'

     pinMode(eyes, OUTPUT);

                   ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected ',' or '...' before numeric constant

 #define OUTPUT 0x1

                ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:19: note: in expansion of macro 'OUTPUT'

     pinMode(eyes, OUTPUT);

                   ^

In file included from C:\Users\Utente168\Desktop\test\test.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:25: error: ISO C++ forbids declaration of 'pinMode' with no type [-fpermissive]

     pinMode(eyes, OUTPUT);

                         ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:36:13: error: 'echoPin' has not been declared

     pinMode(echoPin, INPUT);

             ^

In file included from sketch\test.ino.cpp:1:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:43:15: error: expected identifier before numeric constant

 #define INPUT 0x0

               ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:36:22: note: in expansion of macro 'INPUT'

     pinMode(echoPin, INPUT);

                      ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:43:15: error: expected ',' or '...' before numeric constant

 #define INPUT 0x0

               ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:36:22: note: in expansion of macro 'INPUT'

     pinMode(echoPin, INPUT);

                      ^

In file included from C:\Users\Utente168\Desktop\test\test.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:36:27: error: ISO C++ forbids declaration of 'pinMode' with no type [-fpermissive]

     pinMode(echoPin, INPUT);

                           ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:36:5: error: 'int Mark::pinMode(int, int)' cannot be overloaded

     pinMode(echoPin, INPUT);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:5: error: with 'int Mark::pinMode(int, int)'

     pinMode(eyes, OUTPUT);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:37:13: error: 'trigPin' is not a type

     pinMode(trigPin, OUTPUT);

             ^

In file included from sketch\test.ino.cpp:1:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected identifier before numeric constant

 #define OUTPUT 0x1

                ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:37:22: note: in expansion of macro 'OUTPUT'

     pinMode(trigPin, OUTPUT);

                      ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected ',' or '...' before numeric constant

 #define OUTPUT 0x1

                ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:37:22: note: in expansion of macro 'OUTPUT'

     pinMode(trigPin, OUTPUT);

                      ^

In file included from C:\Users\Utente168\Desktop\test\test.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:37:28: error: ISO C++ forbids declaration of 'pinMode' with no type [-fpermissive]

     pinMode(trigPin, OUTPUT);

                            ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:37:5: error: 'int Mark::pinMode(int, int)' cannot be overloaded

     pinMode(trigPin, OUTPUT);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:5: error: with 'int Mark::pinMode(int, int)'

     pinMode(eyes, OUTPUT);

     ^

exit status 1
Errore durante la compilazione per la scheda Arduino/Genuino Uno.




La libreria con il relativo file .cpp รจ la seguente:
Code: [Select]

#ifndef Mark_h
#define Mark_h
#include "Arduino.h"
#include "Servo.h"
class Mark
{
    const int eyes = 16;
    const int echoP = 14;
    const int trigPin = 15;

    Servo   l_shoulder_pitch, l_thigh_yaw, l_shoulder_roll, l_elbow_roll, l_thigh_roll, l_thigh_pitch,
            l_knee_pitch, l_foot_pitch, l_foot_roll, r_shoulder_pitch, r_thigh_yaw, r_shoulder_roll,
            r_elbow_roll, r_thigh_roll, r_thigh_pitch, r_knee_pitch, r_foot_pitch, r_foot_roll;

   
    l_shoulder_pitch.attach(A0);
    l_thigh_yaw.attach(A5);
    l_shoulder_roll.attach(2);
    l_elbow_roll.attach(13);
    l_thigh_roll.attach(3);
    l_thigh_pitch.attach(A4);
    l_knee_pitch.attach(A3);
    l_foot_pitch.attach(A1);
    l_foot_roll.attach(A2);
    r_shoulder_pitch.attach(11);
    r_thigh_yaw.attach(6);
    r_shoulder_roll.attach(4);
    r_elbow_roll.attach(12);
    r_thigh_roll.attach(5);
    r_thigh_pitch.attach(7);
    r_knee_pitch.attach(8);
    r_foot_pitch.attach(10);
    r_foot_roll.attach(9);

    pinMode(eyes, OUTPUT);
    pinMode(echoPin, INPUT);
    pinMode(trigPin, OUTPUT);

    public:
        Mark();
        void eyesOn();
        void eyesOff();
        void eyesBlink();
        void wait();

};
#endif // MARK_H


.cpp
Code: [Select]

#include "Mark.h"

Mark::Mark()
{

};

void Mark::wait()
{

};

void Mark::eyesOn()
{
    digitalWrite(eyes, HIGH);
};

void Mark::eyesOff()
{
    digitalWrite(eyes, LOW);
};

void Mark::eyesBlink()
{
    digitalWrite(eyes, HIGH);
    delay(500);
    digitalWrite(eyes, LOW);
    delay(500);
};


Qualcuno sa aiutarmi?
Grazie mille in anticipo.

Go Up