1

I'm learning "Arduino" (I don't have previous knowledge of microcontrollers). I have few questions:

  1. What is the difference between programming a microcontroller in C and programming in "Arduino?"

  2. Is it a good idea for beginners to start programming microcontrollers in Arduino and then start learning to program in C?

  3. I have Arduino Uno with an Atmega328P-PU microcontroller. What are some other microcontrollers which can be used with this board? What are differences between various microcontrollers which can be used with this board?

  4. If a microcontroller is already programmed, can we download the program from it to a PC and edit it in Arduino IDE? Or it is like a .exe on a PC, once compiled we can't get source, all we can do is reverse engineer?

That's it :)

2
  • 1
    #2 is a "religious" question. The answer will vary from one end of the spectrum to the opposite, depending on whom you ask. Even if we manage to raise above the "microcontroller religions", the answer would still depend on your answer to "What are your goals? Why are you learning this?"
    – Nick Alexeev
    Commented Jan 9, 2016 at 23:40
  • 1
    #2 IMO only those who understand programming in C can make some custom functions for Arduino, others just copy&paste all the day and seek answers from forums like this. The only advantage is easy moving to different arduino platforms.
    – Marko Buršič
    Commented Jan 9, 2016 at 23:50

4 Answers 4

4
  1. The Arduino IDE uses C++ primarily, which it preprocesses in order to make compilable. But you can still for the most part use C in the Arduino IDE and it will just work as normal; there's nothing requiring you to use C++ or the Arduino libraries (or even the Arduino IDE) for most tasks.

  2. Not touching this one. And in the end it doesn't matter terribly since they're very close.

  3. Any of the ATmegaXX8 or ATmega8 chips will fit the socket. Note that they will require separate cores if you're using the IDE. And you can use any chip without the board in the IDE as long as you can find a core for it.

  4. Not if you use a traditional compiled language to program it. If you use a VM then you conceivably could, but you'd have the source on your system regardless.

1
  1. Nothing really. The Arduino language is C++, a super-set of C. It contains a library of routines which are automatically included and linked, as well as a small amount of pre-processing to hide some of the pitfalls of C (e.g., automatically adding function prototypes for all functions to the top of your program so function ordering isn't something you now need to think about). Other than that, it is just C++, which is C with bells.
  2. If you learn the Arduino language you are learning C. If you learn C first then it gives you a good grounding in how to program the Arduino. Either way, by the time you have written your first Arduino program, you will be programming in C.
  3. There are a number of chips by Atmel that will work. You need, besides the "core" that Ignacio mentions, a board definition which defines what pins do what and what chip is in use. You also need a bootloader for that specific chip and some way to install that bootloader into the chip. There are tutorials on how to do that for commonly used chips - more uncommon ones may not have a bootloader readily available.
  4. When you program for the Arduino you are compiling the software. That is turning the source code first into object code and then linking the object code into an executable format - almost exactly the same as a .EXE on Windows. There is nothing you can do to "undo" that, only disassemble the raw instructions into assembly language and try to interpret what it is doing, which with assembly is a bit of a black art since it can be somewhat cryptic.
1

What is difference between programming microcontroller in C and programming in Arduino?

The difference is that the Arduino core includes a set of functions and classes (C++) to make Arduino boards easier to program.

Is it good idea for beginners to start programming microcontrollers in Arduino and then start learning programming in C?

The whole idea with Arduino is to make it much easier to start embedded programming in C and/or C++.

I have Arduino Uno board Atmega328P-PU microcontroller. What are some other microcontrollers which can be used with this board? What are differenes between various microcontrollers which are used with this board?

None. This is the controller for that board (though there are "smaller" versions).

If microcontroller is already programmed, can we download program from it to PC and edit it in Arduino IDE? Or it is like .exe on PC, once compiled we can't get source, only we can do is Reverse Eng.?

This you will have to explain better. Sounds like something bad and you should avoid that (or at least do not ask people to help you do a bad thing).

1

What is the difference between programming a microcontroller in C and programming in "Arduino?"

The default language is C++, but you can program in C. Thus the difference is "not much".

Is it a good idea for beginners to start programming microcontrollers in Arduino and then start learning to program in C?

Ah, if you program the Arduino you will be learning C. So "goodness" doesn't really enter into it.

I have Arduino Uno with an Atmega328P-PU microcontroller. What are some other microcontrollers which can be used with this board?

You could conceivably remove the chip and replace it with an Atmega168P. I'm not sure why you would want to.

What are differences between various microcontrollers which can be used with this board?

RAM, program memory (flash) size, and EEPROM size.

If a microcontroller is already programmed, can we download the program from it to a PC and edit it in Arduino IDE? Or it is like a .exe on a PC, once compiled we can't get source, all we can do is reverse engineer?

No. Like a PC, you can't get the source back. The compiler is a good, highly optimized one. The generated code won't look like the source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.