Created library wont upload :/

Hello :slight_smile:

I've been trying to follow the library tutorial(http://arduino.cc/en/Hacking/LibraryTutorial) very thoroughly, but the sketch won't upload. Anybody know what's wrong here? The compiler tells me the following:

expected unqualified-id before '.' token

In file included from sketch_aug26a.ino:1:
/Users/Bobby/Documents/Arduino/libraries/Morse/Morse.h:6: error: expected identifier before '.' token
/Users/Bobby/Documents/Arduino/libraries/Morse/Morse.h:6: error: expected unqualified-id before '.' token
sketch_aug26a:3: error: expected unqualified-id before '.' token
sketch_aug26a.ino: In function 'void loop()':
sketch_aug26a:11: error: 'morse' was not declared in this scope

I'm pretty sure everything is typed in perfectly correct, and I even tried with a downloaded copy from the tutorial mentioned. It that one it says that WProgram.h is missing, which I tried to change to Arduino.h instead, like it actually says in the tutorial.

I hope someone can give me a hint :slight_smile:

Peace!

I've been trying to follow the library tutorial(http://arduino.cc/en/Hacking/LibraryTutorial) very thoroughly, but the sketch won't upload. Anybody know what's wrong here?

Yes. You didn't post YOUR code.

Morse.h

#ifndef Morse_h // prevents from including twice
#define Morse_h // prevents from including twice

#include <Arduino.h>

class Morse
{
  public:
    Morse(int pin);
    void dot();
    void dash();
  private:
    int _pin;
};

#endif

Morse.cpp

#include "Arduino.h"
#include "Morse.h"

Morse::Morse(int pin) 
{
	pinMode(pin, OUTPUT);
	_pin = pin;
}

void Morse::dot()
{
  digitalWrite(_pin, HIGH);
  delay(250);
  digitalWrite(_pin, LOW);
  delay(250);  
}

void Morse::dash()
{
  digitalWrite(_pin, HIGH);
  delay(1000);
  digitalWrite(_pin, LOW);
  delay(250);
}

Moresetest.ino

#include <Morse.h>

Morse morse(13);

void setup()
{
}

void loop()
{
  morse.dot(); morse.dot(); morse.dot();
  morse.dash(); morse.dash(); morse.dash();
  morse.dot(); morse.dot(); morse.dot();
  delay(3000);
}

keywords.txt

Morse	KEYWORD1
dash	KEYWORD2
dot	KEYWORD2

Cutting and pasting all the code you posted into tabs in the IDE results in several errors. Changing #include <Morse.h> to #include "Morse.h" in two places resulted in:

Binary sketch size: 1,306 bytes (of a 32,256 byte maximum)

Putting the Morse.h and Morse.cpp files in the Morse folder in the libraries folder in the sketchbook folder, and putting MorseTest.ino in MorseTest in the sketchbook folder would have eliminated the need to change the <> to "" in the include statements.