Fairly new with Arduino and arduino libraries. I need an example to understand.

I need a simple example for Arduino library.

I read it And it's a bit complicated to me And I understand better from code examples.

i need to build library for arduino. Inside the library I need to have 2 functions that receive 3 string values each and the function needs to connect the values to big string and send the value created whit Serial.println(the new value);

I need it only for demonstration So the values are not important to me. It just so that I would learn from that. And I want to use it that way.

className.Function1("val1", "val2", val3");
className.Function2("val1", "val2", val3");

Which extension files need to keep the files? H CPP??? Of course I tried to take ש libraries from arduino but them very complex.

If anyone has an example as I wanted I'm sure it will help me understand.

Why do you need a class to do this?
Why do you need two different functions to do what appears to be the same task?
Why do you, incorrectly, think that sending all the data in one call is ANY different from sending it using three calls?

None of this is meant to dissuade you from learning to create a class or a library, but from what you've said, what you are trying to do is not necessary.

If you are going to define a class, that definition happens in a file with a .h extension.
If you are going to implement a class, that implementation happens in a file with a .cpp extension.

Thank you,
I wrote functions in arduino and I use them in all my projects and I want to make them a library for my all projects in this way my code will be more organized. but I do not know how to write a library and put my functions insid this library. Is there a way to make a file of Arduino (*.ino only with functions and without setup and loop functions) to library?

Is there a way to make a file of Arduino (*.ino only with functions and without setup and loop functions) to library?

As in "Is there a magic button to push?"? No.

Creating a class definition, in the proper kind of file, and implementing it in the proper kind of file, is fundamental to C++. I can't see why you are having difficulties.

What have you tried?

Thank you,
I am a c# programer and no c++ (New with arduino, I know how to program to Arduino) and it confuses me (the libraries confuses me, CPP files H files where to write my code.....), C# libraries is completely different. That's why I think a small example will help me a lot. Sorry I do not think it will help me a lot, I know it will help me a lot. :slight_smile:

C# libraries is completely different.

Not if you really have progressed beyond the one-class-does-it-all stage. The major difference between C++ and C# is that in C# the class is defined and implemented in one file, and in C++, the class is defined in one file and implemented in another.

There are plenty of relatively simple C++ libraries available for the Arduino that have a header file (.h) and a source file (.cpp). They show what does in each file.

It is even possible to put the class implementation in the header file (like C#) does it. I would not.

It is even possible to put the class definition, the class implementation, and the class usage in the .ino file. Though I'll personally come kick your ass all over the place if you do that.

That's why I think a small example will help me a lot. Sorry I do not think it will help me a lot, I know it will help me a lot. :slight_smile:

The library tutorial that you link to is pretty good. Perhaps the issue is that you don't know what Morse code is, so the class being developed is not interesting. Is that the case? If so, perhaps we could come up with a different example.

Thank you for your patience.
I tried to do it (the Morse code) and it did not work for me. I think I did something wrong. And for that I am looking for something short and easy that I can learn from it. I searched on Google and not found example but I'm sure there is full examples I would be happy if someone would give me a small example or link to tutorial.

I tried to do it (the Morse code) and it did not work for me.

"It did not work" is too lame to gather any sympathy. You expected something to happen. Something happened. If the two things were the same, it is unlikely that you would say that "it didn't work". So, all we know is that what actually happened is not what you wanted/expected. But, we haven't a clue what actually happened or how that differed from what you wanted/expected.

I think I did something wrong.

Now, that I can agree with. But, that's a little like saying "How do I get to Chicago?". Without knowing where you are starting from, and how you are traveling, "head towards Chicago, and stop when you get there" is all we can say.

Let's deal with the issues you are having with the Morse code example, or your specific example, before dealing with other possible examples.

The rotary encoder library in my code repository (link below) is really simple. Maybe that can help. There are a lot of other small libraries in there that you cold look at.

Libraries in Arduino are not precompiled libraries. Rather they are just a C++ class definition that encapsulates some functionality that gets included and compiled in the code every time you use it. Simple scheme that mostly works ok and simplifies things for most people.