How to control Arduino Duemilanove with C language

I am a C beginner and an Arduino BEGINNER using wikihow website "Write-Arduino-Software-in-C" and I've D/Led eclipse, WinAVR, etc, as the site explains. Step 3 is where I start to loose it. My setup must be flawed. Anyone know how I can change / run Blink sketch from eclipse instead of the sketch board in Arduino software?

Any information would be helpfull. Thank you!

http://www.wikihow.com/Write-Arduino-Software-in-C is the website. I understand this is a huge undertaking without sitting in front of my screen to see what I've "messed up," but any information would be helpful. Also, I will be on for quite a while so if you have any questions for me, please let me know.

Well, I use Eclipse (for the day-job), but is there a really, really good reason for not using the simplified IDE provided by the Arduino? Seriously, there's a much bigger community here.

I agree, if you are a beginner to both C and Arduino you are far better off using the standard Arduino IDE. You gain little in my opinion other then having a much better editor. You can always 'upgrade' later to eclipse after you have mastered the basics using the arduino IDE. And AWOL brings up a good point in that asking for help with software problems here if your using eclipse will probably result in less feedback as eclipse users here are a small subset I'm sure. Both IDE are using the same compiler, linker, and uploader so there is no fundamental differences between those two IDEs in context with Arduino. Or maybe I'm missing something? Other then the editor what are the advantages of using eclipse over arduino IDE?

Lefty

Thank you AWOL and lefty for your responses.

I must code in C per the directions...

"We would prefer that you use C directly to control the module: http://www.wikihow.com/Write-Arduino-Software-in-C"

not in Arduino (C-based) language, or so I assume. I think the project is to identify if I can link the C code to the Arduino board without the interface being simple, as is the case in the Arduino software. I've already run a few of the example programs in the Arduino software successfully. Can you assist or recommend another IDE that I should use to interface the board and C coding?

I must code in C per the directions...

Why do you feel that it is necessary to follow directions on some random web site? It would be one thing if an instructor was suggesting that you not use libraries, etc., but random instructions on the web?

You can still use the Arduino IDE to program the Arduino in C. The only thing that you do not provide is the main() function.

These were not directions from a random website. My quoted text from the last post was from an email I received. The link was given as an aid by someone who knows more than I do about this topic! The reason I was asking if there was a more user friendly / easier IDE is because I do not HAVE TO use the linked website and I am not having luck with the interface I was told about. The wikihow website was just a recommendation.

So PaulS, the example programs are not written in C, correct? They are written in a C-based Arduino language, right? And, the only difference between them is the main function call? That is helpful, thank you. The quote I mentioned earlier, "We would prefer that you use C directly to control the module" is not referring to the environment? That is how I took it, but again, I am a novice at C programming!

My quoted text from the last post was from an email I received.

From who? Is this person in any position to require that you not use the Arduino IDE? Like an instructor for a class?

So PaulS, the example programs are not written in C, correct?

Which example programs? The ones available with the Arduino IDE are written in C. The IDE generates a main() function that calls init(), setup(), and loop() in an endless loop. The init() function activates the hardware. You provide the setup() and loop() functions.

The quote I mentioned earlier, "We would prefer that you use C directly to control the module" is not referring to the environment?

As I read it, the IDE is not what is being discouraged. It is the use of libraries that have been written to make using specific hardware easier. I guess the point is for you to learn how to control all the hardware rather than relying on what others have done to control that hardware.

I see pros and cons to that approach. On the one hand, it is good to learn how to control all the hardware. But, as in any programming task, like doubly-linked lists, queues, stacks, etc. know how to do something, and doing it efficiently, in a thread-safe manner, in a way that can be extended to manipulate objects of a different type, etc. are two different things.

Learn how a library does something, well enough to know whether you could do something as good, or better. Then, if you can do it better, do it better. If not, use the library.

The email is from the project requestor.

The example programs I was referring to are those in Arduino.exe under File / Examples.

Another related question: How do I know where (which library) a function comes from? I am looking for the pinMode() and digitalWrite() that are used in the Blink sketch example. I can't seem to find them in the Arduino library folder or on the internet C program library lists. Plus, there are no library #include in the Blink sketch.

That functions are at: ../Arduino/hardware/arduino/cores/ then open the wiring_digital.c file. If you really want to use plain C and no arduino functions you can read my first tutorial about doing exactly that using the AvrStudio which is the oficial IDE from Atmel to use with their micro-controllers. http://hekilledmywire.wordpress.com/

If you are a newbie in the area I still suggest you to use the Arduino IDE because using it and its functions you will do much more work with less hassles and problems, but all that you can write in AvrStudio you can write using the Arduino IDE because the compiler is the same and it will generate the same code and will recognise all the registers names like the DDRB, PORTB, PINB, and all the other ones.

The email is from the project requestor.

Well, that makes a big difference in whether to pay attention to it, or not.

I hope that you took the "reinvent the wheel" attitude into account when bidding on the project.

Senso, or anyone else who can help...

The code on your website, which I haven't attempted (still D/L ing), it shows that PORTB is the Pin 13 on the Arduino board. Where can I find that type of architecture information? In other words, how do I know that port B is equivalent of pin / LED # 13? I assume this answer will be different depending on my board type... which is Duemilonove.

Thanks for your help!

In other words, how do I know that port B is equivalent of pin / LED # 13? I assume this answer will be different depending on my board type... which is Duemilonove.

The file pins_arduino.c in the Arduino core defines the pin mapping from port.pin to arduino pin number. The conditionals determine which chip mapping to use depending on the board type selected on the Arduino IDE.

Lefty

Are you required to use Eclipse as well? Or do you have previous experience with it? I'm sure Eclipse is very nice, but it adds a extra layer of complexity to the whole thing, and you might be better off using your favorite text editor and command-line tools to compile/download (which would still fit in the requirement of "We would prefer that you use C directly to control the module")

(did you download the correct eclipse? Last time I looked at it, there were different downloads for C developers vs Java Developers (for example), and the site you mention doesn't say specifically which version to download (it MIGHT not matter, since it's adding its own plugins/config/etc. But it might.))

While going through the steps and copying Senso's website code for "Blinky" program, I was able to run it a couple days ago successfully. I unsuccessfully ran my own code and I am now unable to successfully run the Blinky code again. The cmd prompt error (after I typed in "avrdude -p m328p -c avrisp -P com12 -b57600 -F -U flash:w:MyBlinker.hex" per the www.hekilledmywire.com website) is...

"avrdude: stk500_getsync(): not in sync: resp=0x00 avrdude done. Thank you."

(FYI, I renamed Blinky to MyBlinker) and my other code is MyBlinker2.)

Can anyone tell me how to get "synced," or point me in the right dierction?

WestFW, I still have DevC++ from college, but I don't know how to get the board and the code/computer to talk using DevC++, the cmd prompt (as in Senso's suggestion), or Eclipse. I got the cmd prompt method for avrdude working, but now I'm "not synced" as in my preious post!

I did D/L the incorrect Eclipse initially, but then got the correct version afterward (or so I think). I have yet to get it working, so I can't confirm it is the correct one!