I picked up the Arduino about a month ago and I’ve been playing with some basic stuff like the hello world of micro controllers. I'm now to the point that playing with examples are wearing off and getting a bit dull. I have had a semester of basic programming in vb, but the book we used was POORLY written, and the instructor was not too far behind. I want to become familiar with programming the Arduino, but knowing where or how to start is the problem. I grabbed "Getting Started with Arduino" by Massimo Bansi. Along with that, this week during my lunch at work, I printed the syntax from the reference section on this site, 81 pages worth.
What is a good way to learn a programming language?
What is a good way to learn a programming language?
Read forums like this and study posted working code. Find a project that interest you and start your research. Google can provide a lot of tutorial information.
I have been looking on google, but Ive been having trouble finding good explanations on how to learn the language. Actually, I also printed the Arduino Programming Notebook by Brian W. Evans, and that has been some help on the general functions and commands.
Trying to "learn the language" in the abstract is hard and often not the best approach. At least not for me, and I've learned a few.
Learning a language "in practice", which is to say as a side effect of getting a project done, has a nice way of prioritizing the learning into just what you need at the moment. So, find a project, get stuck, hit Google, do a little just-in-time learning, repeat.
When you have a project in mind, your first stop should be Google anyway, to find out what else has been written on the same topic. Read all the code you can find - you get better much faster reading well-written, working code than by reading reference material. Finding a sample or reference sketch to start from can be very helpful.
A word on workmanship. Take the time to study coding styles, and pick one to use as your own. Apply it carefully in everything you write so your eyes will learn to spot discrepancies; this will save you half of your debugging time. Nothing says "newbie" more than code that looks like an unmade bed, and bugs love to grow in poorly laid out code. The compiler cares about every single character and so should you.
Debugging is as important as coding. Unfortunately, it is twice as hard, so if you write something so clever you don't really fully understand it, you won't have a prayer of debugging it. Favor simplicity in what you write and learn to use Serial.print() to confirm what's going on. It's cheaper to think about "How am I going to know whether this is working?" when you write it than later when you're debugging it.
Billroy, thank you for your .02. I guess I'm use to going about things in a textbook method. While doing some googling, I came across 2 projects that will be useful for me at work. One is to use a 2x16 LCD to display time, temp and maybe humidity. Another helpful project that I ran across is to help keep track of how long I work on a project. I am a Machine Designer, working on designing and building machines that will be used in production for companies such as CNH, Harley Davidson, and Zero Zone. When working on multiple jobs, it can be easy to forget to track your time for that job.
Other project ideas I have are model railroading based. Being a model railroder at heart, but living in an apartment makes it hard to practice a hobby that you love in an environment that does not offer the space needed.
Thinking of simple project ideas to become familiar with code, why not take something familiar and duplicate the known with something new. Where would we be today without logic gates?
I think thats where I'll start, with simple logic gates such as and, nand, or nor...etc.
I find something I want to do/achieve... a prop or a project of some kind.
Then I break it down into steps, that I need to do.. and research on how to get each step down, and then work on integrating them all on the same sketch.
getting a list of all external components I am going to use.. getting all specs/datasheets together...etc.. giving the datasheets a 'once over' to get familiar with how the device works..
googling or searching forums for others who have undoubtably had these same questions before me.. and seeing their approach or using public libraries..etc..
it all helps for me.. plus posting here and getting feedback from the brain trust here..
Reading the code in libraries is a good way to learn some coding techniques. And the libraries that support multiple instances of the objects they create are examples of C++ Object Oriented programming.
I'm almost always teaching beginners but last week in a 4-day workshop some high school kids blew my mind. Two girls who were building a complex LED display asked me, "How do we initialize values in a multidimensional array in 'C' "? This right after explaining to one guy why stuff that is done once should be in SETUP and not in LOOP.
And start building physical things right away. Arduino is not supposed to be an academic environment. I had three kids who got ultrasonic sensors hotglued to servos and looking around. One made a display that showed the direction of the nearest thing found on a circle of LEDS, and the closeness on a vertical strip of LEDs.. Most of these kids had never touched Arduino before.