I am trying to learn the Arduino programming, but can't seem to find a simple tutorial for beginners. I have tried following along with the simple tutorials such as Blink and AnalogueRead etc, and they work if I use the examples and upload them to my Arduino, but the moment I try to "copy" them by writing the code myself, and then uploading it, it all goes to hell in a handbasket, and I get multiple error messages. I need something to explain the correct order and process of programming, and what all the terms (like void, sensorPin, loop, int etc) mean, and in what order they have to be used. Like what are semi colons for, when do they have to be used?
I have been working on this for the last 4 hours, and have got nowhere, as far as being able to write a simple code myself is concerned. I don't want to waste you peoples precious time, so if you can point me to a good learning resource, I may be able to muddle through it by myself. Maybe theres a thread here that covers what I need. I've looked, but haven't found one.
Use Google to find some tuotials on C++. That is the programming language used by the IDE. There you will find most of your questions answered, like what the void means and what the semicolons are for.
The only thing you need to know about the IDE is that it does a few things for you. This won't make sense until you learn a little about C++, but I'll put it here anyways.
The IDE hides the main() function from you. In Arduino main calls setup once and then calls loop over and over in an infinite loop. It also writes all your function prototype for you, so you can just implement a function anywhere and expect it to work anywhere.
google "beginning C for arduino free pdf" and read the first 100 pages.
get use to the red text when you compile in the beginning just scroll up to the first red line and look for the number. Theres a number at the bottom left that tells you where your curser is just move to the same number line and fix the problem the compile and repeat until its fixed.
Learning to program is like learning to play a musical instrument. You have two things you need to learn: the musical instrument (where they keys are, what they do), and music itself.
A tutorial or reference can tell you what the various keys on a saxophone do, but they cant tell you how to make music. Music is something you do, not something you know about.
You don't need to learn C++ at all. There is a "front end" of "library" functions that you use for specific pieces of hardware. Those are written in C++ but you never do C++ things like instantiate a class, overload functions, use templates, etc. Initialization and setup functions are all high level functions that do an excellent job of hiding processor specific details from you.
boolrules:
You don't need to learn C++ at all. There is a "front end" of "library" functions that you use for specific pieces of hardware. Those are written in C++ but you never do C++ things like instantiate a class, overload functions, use templates, etc. Initialization and setup functions are all high level functions that do an excellent job of hiding processor specific details from you.
If you get really interested, THEN learn C/C++ and start reading datasheets. Have fun.
Oh, yeah, you need to connect your grounds together.
You do need to learn C++ basics though, like what the semicolons are for and what void, and int, and such mean. And what functions do and how they are written. Sure you don't need all that high class stuff, but if you don't have the basics you won't be able to use any of those libraries.
So maybe we should be saying get a C tutorial instead of a C++ tutorial. Either way, the basics are the same.
Thank you all for your input, I really appreciate it. Yes, I did start with http://www.arduino.cc/, but thats where I started to come unstuck, when I tried to practice typing the code myself, I started getting errors. Thanks for the tip, gpop1. And yes, I already know what I want to do with it, I'm modifying an MPPT Solar battery controller, which didn't work when I bought it from a Chinese manufacturer, and they gave me refund, and told me to keep the carcass. So I'm using the case, heat sink and power components of the buck converter, and want to control it with an Arduino Uno. The original circuit had an ATMega IC to control it, but I got a bit lost trying to draw the fairly intricate circuit around that area, and decided it would be easier to start from scratch with the Arduino.
Also, gpop1, I hope that was a joke "read the first 100 pages..."
Reading and trying to understand existing programs - such as the examples that come with the Arduino IDE and the programs that are discussed on this Foum - is a good way to get experience and to focus your learning on specific things that you don't understand.
A huge amount of programming involves patterns and techniques that can be adapted from one activity to a different one - watch for them.
MikeKoens:
Also, gpop1, I hope that was a joke "read the first 100 pages..."
Thanks for your help guys, I'm looking at "C".
no joke. if you have a basic understanding you should be able to speed read that in a few hours. After page 100 its not about the basics any more so you can leave that till later. (you can cheat and just watch you-tube videos).
learning to troubleshoot requires some basic skills like serial printing and understanding things like the difference between a byte and a int and what happens when you move a float into a int etc.
It agree it does help to have a project or a goal to aim for, my first code was a dual egg incubator with a lcd display plus a lot of extra toys like motorized turner, rtc, I/r buttons, pwm peltiers, etc.
I wrote that 3 weeks after I found out what a arduino was and I had never played with C before. Serial print became my best friend while troubleshooting especially when you find the compiler is not that cleaver and will happily allow you to make dumb mistakes like using a single = in a if statement. (if you have read the first 100 pages you will know what that means...lol)
If you have some basic programming knowledge, looking at the arduino reference pages and all the example code on the arduino site should get you a good start. Also you will need to have a fairly good idea of how your gizmo works to be able to interface with it.
Hi friends, Thanks again for more advice. And, gpop1, a speed reader I aint! I tend to fall asleep in front of a computer about 1/3 the way through the second page of anything on the screen. That said though, I have discovered opensourcehardwaregroup.com, and I'm really finding those tutorials very helpful. And zoomcat, no I don't even have basic programming knowledge, I've been around electronics for about 55 years of my 60 year life, and computers for the last 30, but I have never touched any sort of programming language, so I really am a "noob".
Another problem I'm noticing now is that the arduino IDE, and Google Chrome are crashing very frequently, while running Arduino.exe, and it seems to be related to Java, as I usually get the following error message.
"Java(TM) Platform SE Binary has stopped working".
But not always, sometimes the IDE window just disappears without a trace. When I click on the exe file again, the program starts again, without hesitation, but back at the default start screen, not the sketch I had been working with. Could it have something to do with the program being installed in the downloads folder (which is where Winzip installed it), instead of in the program files area?
Post a copy of the code you wrote and ask for someone to help you. There are plenty of people here to help.
I have had challenges ( problems) and get plenty of help here.
If you want a book, Amazon has a book titled Learn Arduino programming in 24 hours. It will take longer than that but it is broken down into 24 lessons that take about an hour each. I have it on my Kindle.
Hope this helps a little.
Ken
Before I started out, I went to the arduino learn page and read all the functions associated with the language. This should give you an understanding of what sketches you could write or form with the allowed syntax.
Then, set a goal on what you want your arduino to do. One small step at a time. Build it from there. You will come across challenges due to the learning curve, electronics, etc. But the community helps out a lot so your level of programming would be determined by your willingness to achieve your set goals.
The example sketches in the IDE help a lot too.
I'm a noob myself and have just been coding for 2 weeks now but I have learned to measure voltage, set run times, measure temperature, control fans manually/variably/automatically, count events, etc. Now I am learning to deal with the limitation of some devices available to me here so that I can properly display the data I want to see on an LCD.
And expect to run to the electronics store daily. I have most of the 1/4 - 1/2 resistors already, transistors, relays, etc. Nice to have them on hand so you can keep focusing on your builds.