„Ha szeretnek irni egy Morse.h -t merre kell elinduljak?”
Kezd el tanulmányozni a Wiringet: http://avr.tavir.hu/modules.php?name=Fo ... ght=wiring
Inkább itt kérdez a tanfolyamon (és Arduinón) túlmutató dolgokról
Kód: Egész kijelölése
If you tried the new sketch, you probably noticed that nothing from our library was recognized by the environment and highlighted in color. Unfortunately, the Arduino software can't automatically figure out what you've define in your library (though it would be a nice feature to have), so you have to give it a little help. To do this, create a file called keywords.txt in the Morse directory. It should look like this:
Morse KEYWORD1
dash KEYWORD2
dot KEYWORD2
Each line has the name of the keyword, followed by a tab (not spaces), followed by the kind of keyword. Classes should be KEYWORD1 and are colored orange; functions should be KEYWORD2 and will be brown. You'll have to restart the Arduino environment to get it to recognize the new keywords.
It's also nice to provide people with an example sketch that uses your library. To do this, create an examples directory inside the Morse directory. Then, move or copy the directory containing the sketch (let's call it SOS) we wrote above into the examples directory. (You can find the sketch using the Sketch > Show Sketch Folder command.) If you restart the Arduino environment (this is the last time, I promise) - you'll see a Library-Morse item inside the File > Sketchbook > Examples menu containing your example. You might want to add some comments that better explain how to use your library.Hikapu48 írta:Hali fodor99!
Boldogultál a SOS.lib szerkesztéssel?
Én a nagyján át vergődtem.
Csak a végén levő, szerkesztőben a Parancsok kiemelése át színezéssel ezt nem értem:Ez nem akar össze jönni!Kód: Egész kijelölése
If you tried the new sketch, you probably noticed that nothing from our library was recognized by the environment and highlighted in color. Unfortunately, the Arduino software can't automatically figure out what you've define in your library (though it would be a nice feature to have), so you have to give it a little help. To do this, create a file called keywords.txt in the Morse directory. It should look like this: Morse KEYWORD1 dash KEYWORD2 dot KEYWORD2 Each line has the name of the keyword, followed by a tab (not spaces), followed by the kind of keyword. Classes should be KEYWORD1 and are colored orange; functions should be KEYWORD2 and will be brown. You'll have to restart the Arduino environment to get it to recognize the new keywords. It's also nice to provide people with an example sketch that uses your library. To do this, create an examples directory inside the Morse directory. Then, move or copy the directory containing the sketch (let's call it SOS) we wrote above into the examples directory. (You can find the sketch using the Sketch > Show Sketch Folder command.) If you restart the Arduino environment (this is the last time, I promise) - you'll see a Library-Morse item inside the File > Sketchbook > Examples menu containing your example. You might want to add some comments that better explain how to use your library.
[/list]
Köszi, a tutorial kvázi meg is oldja a feladatotRobert írta:A c és a h fele
De ez _C_ nyelven kell megírni!
Puska: Arduino libraries vagy library könyvtára...
Ez az Arduino sample
http://arduino.cc/en/Hacking/LibraryTutorial
Eclipse-el megnéztem, a trükk lényege hogy kulcsszó után 1 azaz egy darab TAB-nak kell lenni , akkor szinezkapu48 írta:Hali fodor99!
Boldogultál a SOS.lib szerkesztéssel?
Én a nagyján át vergődtem.
Csak a végén levő, szerkesztőben a Parancsok kiemelése át színezéssel ezt nem értem:
Ez nem akar össze jönni!
[/list]
Kód: Egész kijelölése
dot KEYWORD2
dash KEYWORD2
Morse KEYWORD2
Kód: Egész kijelölése
// Morse01.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);
}Kód: Egész kijelölése
// Morse.h
/*
Morse.h - Library for flashing Morse code.
Created by David A. Mellis, November 2, 2007.
Released into the public domain.
*/
#ifndef Morse_h
#define Morse_h
#include <Arduino.h>
//#include "WProgram.h"
class Morse
{
public:
Morse(int pin);
void dot();
void dash();
private:
int _pin;
};
#endifKód: Egész kijelölése
// Morse.cpp
/*
Morse.cpp - Library for flashing Morse code.
Created by David A. Mellis, November 2, 2007.
Released into the public domain.
*/
#include <Arduino.h>
// #include "WProgram.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);
}Kód: Egész kijelölése
Morse KEYWORD1
dash KEYWORD2
dot KEYWORD2Kód: Egész kijelölése
/*
Morse.h - Library for flashing Morse code.
Created by David A. Mellis, November 2, 2007.
Released into the public domain.
*/
#ifndef Morse_h
#define Morse_h
#if defined(ARDUINO) && ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
class Morse
{
public:
Morse(int pin);
void dot();
void dash();
private:
int _pin;
};
#endif