I bought my first Arduino UNO R3 kit two weeks ago (the Elegoo Super Starter kit) and am stepping through its tutorials. In parallel I'm trying to learn the basics of its C++ based programming language, but that's proving a struggle. I'm impatient to use Arduino on my own projects so I will take a 'copy/paste/edit' approach. It then becomes a matter of finding sketches that cover a particular subject and then tailoring.
I'd therefore appreciate recommendations on Arduino sketch sources that others have found useful please.
I wouldn't even bother with C++ in this instance. Get yourself a copy of Kernighan & Ritchie's the C Programming Language - the best book ever written on C.
--
This message may be freely reproduced without limit or charge only via
the Usenet protocol. Reproduction in whole or part through other
protocols, whether for profit or not, is conditional upon a charge of
GBP10.00 per reproduction. Publication in this manner via non-Usenet
protocols constitutes acceptance of this condition.
Thanks. Arduino apparently uses C++, although the book I?m using, ?Programming Arduino: (Second Edition)? by Simon Monks, mai nly covers C. I gather that is adequate for relatively simple sketches.
Best place to start looking is the library search function from the IDE itself, Sketch -> Include Libraries -> Manage Libraries or control + shift + I.
From there you can search for libraries covering a lot of common embedded hardware devices and software tasks. Most will have links to a repository of the source code for how they're implemented (some are more complicated than others.)
Here is another place that shows how to hook up many of the sensors.
formatting link
Arduino.html
There are lots of people on youtube that have done many things with the Arduino. I have been playing with them for about 2 years. The language is simple, but I am not a programmer. I do it like I do the game of chess. I know how each piece moves on the board, but playing someone that has a basic understanding of the game will beat me in a very short time. I can make simple changes to other's programs but that is it.
Yes, and indeed additionally a convert from the Pi, which has far too much video capability I don't need and don't wish to pay 3 times the price for.
I keep 3 or 4 Arduinos around in case I need one for a bespoke, embedded application which happens from time to time. They will repay the time invested in learning how they tick many, many, many times over. IMHO, they're a fantastic little board for the price.
--
This message may be freely reproduced without limit or charge only via
the Usenet protocol. Reproduction in whole or part through other
protocols, whether for profit or not, is conditional upon a charge of
GBP10.00 per reproduction. Publication in this manner via non-Usenet
protocols constitutes acceptance of this condition.
Thanks to those who suggested useful sources of code, a couple of which I've added to my already extensive 'Arduino Code' bookmarks.
As per my opening post, I am already stepping through the Elegoo tutorials, some 37 projects. And dipping in and out of two other sets.
As also explained, I don't want to master either C or C++. I want to reach the stage I described: minimal competence for a copy/paste/edit approach.
I'm seeking feedback from other Arduino users on the sources they've found most useful to find sketch code to help them with a specific project or section of one.
My current sources apart from tutorial projects are the obvious Google Search, the Arduino Forum, and the Embedded Systems and Micro controllers section of the All About Circuits Forum.
Unless there's a superbly indexed site I haven't yet found, perhaps that's enough.
There is such a site, with wonderful indexes. It is called google, and knowing how to use it effectively is a key modern skill.
It isn't difficult; my 10yo quickly mastered it sufficiently that she demolished my arguments about why we shouldn't get chickens. Made me proud, and glad to get them.
I found books easier to get on with than on screen things but I'm an oldie and a long term programmer.
Arduino for Dummies is good for getting used to Arduino with worked examples.
Arduino Cookbook published by O'Reilly is also very good and goes into programming techniques such as loops, decision structures and variable types. I presume those would be useful to a started in programming. It states the problem (such as You want to send text and data from your Arduino to your pc) and then shows a solution.
--
Regards - Rodney Pont
The from address exists but is mostly dumped,
please send any emails to the address below
e-mail rpont (at) gmail (dot) com
I'm currently ploughing through Simon Monk's 'Programming Arduino, 2nd Edition'. Quite readable up to his first complex example, flashing Morse code to the LED from the serial monitor), mainly because of its use of arrays within arrays ;-(
Went straight to your next recommendation as I hope Monk's book and the online tutorials I'm studying will get me to a stage I can benefit from the Margolis.
A "modern C++" feature that would be very helpful for uP based projects is a smart pointer. You can't really do dynamic memory allocation/de-allocation at will on a processor with 2k of RAM. But you still often need to hold and transfer resources around.
What's a pointer? A pointer holds the address of a _resource_. The ownership status of a resource must always be well-defined. A "unique pointer" object defines ownership of a resource - the object that holds that unique pointer object, which wraps a dumb pointer, "owns" that resource. Unique pointers cant be copied, only moved. If an object holds a unique pointer it cannot be copied, either, or else two owners would exist. Nuh uh.
Sometimes other code needs to hold a reference to a resource. Some logic would like to see what a data buffer contains, but shouldn't "own" the buffer. So there can be an "observer pointer". It can only be used for read-only access to the resource but cannot modify the actual resource's state in any way. The observer container can be both copied and moved. They can be passed to functions, even plain-C functions, taking a const-qualified raw pointer seamlessly but cannot be passed to functions taking a non-const qualified pointer as that would allow write access to the resource.
An advantage of C++ is you can write code to define rule-enforcing data structures like that to, by design, self-enforce safer further design decisions. Along the same lines raw data types like "int" should never be used and passed around to represent something like dollars in a bank account, or velocity. They should be wrapped in an object that enforces assumptions like class Dollars, or class Velocity. A function that computes an output velocity from an input velocity should return a Velocity and take a Velocity argument e.g. Velocity calc_new_velocity(Velocity v) not int calc_new_velocity(int v).
And no, this almost never "bloats the code" if done intelligently the compiler and optimizer will figure out that in almost all cases it can compute a velocity under the hood by just manipulating the raw ints like it would when compiling C. all the boilerplate is mostly for your benefit so it can warn you if you try to do something stupid.
BTW the purpose of the mini-rant isn't to be super-useful advice to a total beginner, but I think it's worth thinking about when beginning any endeavor to consider "where do I want to be in two years time." I think it's worth thinking about how "real code" is written in the 21st century, or should be, and ideally things will go well and one won't want to stay in the sandbox forever.
A lot of Arduino-environment code is bad. but the tools are available so it doesn't have to be that way, so I think it's worth thinking about how to be at a place where one is writing _good_ code in two years time simultaneously, code that can earn money, and not just rote-learning the syntax. and I think that also means learning a bit about software _engineering_ practices simultaneously and not just code-writing.
Agreed. My son taught himself C out of K&R just a few years back, and liked it very well.
H&S was an excellent book, and I used it for several years. However, time has moved on, and the old-time C libraries are showing their age. I still used , but stuff like strdup() and realloc()? Really?
Cheers
Phil Hobbs
--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC / Hobbs ElectroOptics
Optics, Electro-optics, Photonics, Analog Electronics
Briarcliff Manor NY 10510
http://electrooptical.net
http://hobbs-eo.com
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.