Device Driver for Arduino?

Thread Starter

jj8431

Joined Mar 3, 2021
3
Hi,

I have never used an Arduino before, I only have a very basic idea of Arduino, so this question might seem silly, but anyway,
I have this question: I guess some popular devices such as the 1602 LCD module will have a 'library' for it so people will not need to know the technical details? Then what about a device not so popular? Can a user writes a custom library for it and share with others? Or every one have to deal with the low level I/O interface by themselves? Thanks
 

SamR

Joined Mar 19, 2019
3,484
Short answer, yes. Writing libraries is a bit of a higher level occupation than making LEDs blink and there are lots of new libraries becoming available or upgraded all the time. You still need to know the technical details of the device you are using. Libraries just make the interface easier.
 

andrewmm

Joined Feb 25, 2011
1,751
Welcome to the world of Arduino

There is a lot of help on line, not least on the Arduino site,

It took me a while to get used to the setup and main loop, but now love it for ease,

Most all devices you could imagine have libraries that do the work for you
again do a search. Arduino site to start with.

Writing your own library for a device.
Relatively easy IF your a competent C++ programmer.

What I do , is start out with the code in the main program, to test and debug how the thing works.
a lot of use of the SPi / I2C / uart libs etc.

Only when I'm confident with the device, do I consider is it worthwhile packing up into a library as opposed to separate routines in the main program, and how I would like to interface to them.

then I replace my test code section by section with the new functions in the library I have made, , allowing us to test in steps.

BTW:
have a look here for some arduinos that are fast / and cheap,
You will see on the site that paul has a great forum for support and a close relationship with arduino people.
a lot of his work gets included into the main Arduino tree

https://www.pjrc.com/teensy/
 

Thread Starter

jj8431

Joined Mar 3, 2021
3
Welcome to the world of Arduino

There is a lot of help on line, not least on the Arduino site,

It took me a while to get used to the setup and main loop, but now love it for ease,

Most all devices you could imagine have libraries that do the work for you
again do a search. Arduino site to start with.

Writing your own library for a device.
Relatively easy IF your a competent C++ programmer.

What I do , is start out with the code in the main program, to test and debug how the thing works.
a lot of use of the SPi / I2C / uart libs etc.

Only when I'm confident with the device, do I consider is it worthwhile packing up into a library as opposed to separate routines in the main program, and how I would like to interface to them.

then I replace my test code section by section with the new functions in the library I have made, , allowing us to test in steps.

BTW:
have a look here for some arduinos that are fast / and cheap,
You will see on the site that paul has a great forum for support and a close relationship with arduino people.
a lot of his work gets included into the main Arduino tree

https://www.pjrc.com/teensy/
Thank you very much andrewmm, I just donwloaded the Arduino IDE today and tried to play around with it. I have an Arduino UNO at hand, so I guess I can try some basic functions and libraries at least. Your reply did actually answered the questions I haven't even asked yesterday, I'm happy to find out that the libraries are actually C++ classes, which is not unfamiliar to me.

I'm still learning it, if you don't mind I would just ask a further question here instead of finding the answer somewhere later in tones of Arduino documentations by myself.

I noticed there is a Library Manager in the IDE, and it's like a market place has a lot libraries listed. But I couldn't find how to load a local (or my own) library in the IDE. If I wrote a library for a device I created and want to share with others, how could I do that?

Thanks
 

andrewmm

Joined Feb 25, 2011
1,751
Thank you very much andrewmm, I just donwloaded the Arduino IDE today and tried to play around with it. I have an Arduino UNO at hand, so I guess I can try some basic functions and libraries at least. Your reply did actually answered the questions I haven't even asked yesterday, I'm happy to find out that the libraries are actually C++ classes, which is not unfamiliar to me.

I'm still learning it, if you don't mind I would just ask a further question here instead of finding the answer somewhere later in tones of Arduino documentations by myself.

I noticed there is a Library Manager in the IDE, and it's like a market place has a lot libraries listed. But I couldn't find how to load a local (or my own) library in the IDE. If I wrote a library for a device I created and want to share with others, how could I do that?

Thanks
To clarify my comment on C++

Arduino itself is just a front end pre processor to C++
You don't even have to use the Arduino language, many experts po ho it a "beginners code"
I don't agree , but there you go...

The reason most libs are done in C++, is that they are written by experts, see above on experts.

this will give you a basis and example of creating your own "library"
https://www.arduino.cc/en/hacking/libraries

https://www.arduino.cc/en/Hacking/libraryTutorial

As you see there, they are just standard C++ with functions, procedures and methods .

The ones that come with the IDE are "approved" ones,
but I seem to remember there is a way of getting your own "libraries" to appear in your list,
just search

have fun.

Uno is great, we've all had one or two , but are small memory and slow,
others do exist that are transnormal.
 

Thread Starter

jj8431

Joined Mar 3, 2021
3
To clarify my comment on C++

Arduino itself is just a front end pre processor to C++
You don't even have to use the Arduino language, many experts po ho it a "beginners code"
I don't agree , but there you go...

The reason most libs are done in C++, is that they are written by experts, see above on experts.

this will give you a basis and example of creating your own "library"
https://www.arduino.cc/en/hacking/libraries

https://www.arduino.cc/en/Hacking/libraryTutorial

As you see there, they are just standard C++ with functions, procedures and methods .

The ones that come with the IDE are "approved" ones,
but I seem to remember there is a way of getting your own "libraries" to appear in your list,
just search

have fun.

Uno is great, we've all had one or two , but are small memory and slow,
others do exist that are transnormal.
Thanks a lot! Soon after I posted it I found the "Add .ZIP library" menu, I should do more home work before ask. The link in your reply is really helpful, considering using the UNO to get started and buying a more powerful one later.

Cheers.
 
Top