what is the difference between c# arduino C and c++

i have a bit of experince in arduino programming but i want to go further
but i have no idea how :confused:
some of the examples stopped making sense to me
so i want to start a course online on http://www.programmr.com/practice/
its C# will it help or is it only for apps
and an other thing i hope it's ok to ask
i have a raspberry pi and i want to learn more about it so i started a course here http://www.codecademy.com/
about python
is that python is the same used with the raspberry pi or not
thank you :smiley:

its C# will it help

It'll help learning how to program, but may raise unfulfillable expectations.

Some call C# "I can't believe it's not Java"

AWOL:
It'll help learning how to program, but may raise unfulfillable expectations.

Some call C# "I can't believe it's not Java"

please do
so where do i start ?
do i need to go all the way from the beginning
what about python do i need it i've reached 25% in a couple of hours should i complete ?

Python works on any PC operating system. C# is a Windows programming language.

C/C++ is not the same as C# though there may be some similarities.

C/C++ is a lower level language that gets you closer to the hardware - which is why it is used to program the Arduino. But many PC programs, especially where performance is important, are written in C/C++.

In general if you have a good grasp of programming principles in one language you will not have much difficulty using another language.

The only use for Python when using an Arduino is if you want to write a Python program to communicate with an Arduino.
C/C++ is the only language for programming an Arduino.

...R

Robin2:
Python works on any PC operating system. C# is a Windows programming language.

C/C++ is not the same as C# though there may be some similarities.

C/C++ is a lower level language that gets you closer to the hardware - which is why it is used to program the Arduino. But many PC programs, especially where performance is important, are written in C/C++.

In general if you have a good grasp of programming principles in one language you will not have much difficulty using another language.

The only use for Python when using an Arduino is if you want to write a Python program to communicate with an Arduino.
C/C++ is the only language for programming an Arduino.

...R

thats nice but isn't the c++ not for arduino ?
the arduino ide uses normal C
but what about the raspberry pi can you help me with that?
where can i find a good course for arduino
i know conditionals and variables mostly all the basics
but what about the harder side ?

the arduino ide uses normal C

Nope.
You can't have classes in C.

Robin2:
Python works on any PC operating system. C# is a Windows programming language.

...

C/C++ is the only language for programming an Arduino.

To be clear, Python runs on Linux/Unix, OSX, and Windows (some people associate the term "PC" with only Windows).

C# really just specifies the language itself, however there are various runtime environments that support C# and they work on other operating systems and platforms. See Mono and Netduino for examples.

To the OP, I would say that if you are wanting to develop software that runs on microcontrollers and microcomputers, don't bother with managed languages like C# and Java and instead focus on C++ and Python. If you are absolutely new to programming, it may be easier to start with Python before embarking on the great adventure that C++ will bring.

That said, I can't help but to think about much you will probably despise C++ (at least at first) after having learned and mastered Python. Although under the hood Python is implemented in C, the two languages are extremely different from each other in so many ways. People tend to fall in love with the first language they learn (or perhaps more specifically, the one they first master), so I dunno whether to recommend you start with Python first or not!

If you learn (master) C++, all other languages (including assembly) should come easily to you, though you will resent the fact that most others don't give you the control you're used to. For that reason, it may be better to start with C++.

In the end, I suppose the best advice to give is to learn the language that interests you the most! As long as you are fueling a passion of some sort you will continue to get better and of course have more fun.

Tony

I think it really depends upon what your goals are. If you want to code for Windows apps, using Visual Studio is a nice environment for C# and C++. When I taught programming, our intro course was C# and VS. (I think C# was simply Microsoft trying to buck the Java wave.) We wanted to use Java, but it took the better part of three weeks just to teach the IDE (Netbeans) and the fussiness that Java wanted laying things out. C# took one class period. The second course is Java and C++ came after that. All intro courses were grounded in Object Oriented Programming. If you already know C, learning C# is probably a couple of days to learn enough to use its syntax. If you're working with the Arduino exclusively, stick with C and C++.

Yeah, as far as IDE's go, I think Visual Studio is by far the best. There is a plugin called Visual Micro that will allow you to compile, deploy, and debug Arduino sketches. It can be a little quirky, but it works well most of the time (and it's actively being improved). Atmel Studio is another option for Arduino development.

Most of the time, though, I just use Notepad++ for Arduino development (still use Arduino IDE for compiling/deployment, obviously).

robertanthony02:
To be clear, Python runs on Linux/Unix, OSX, and Windows (some people associate the term "PC" with only Windows).

Yes. That is what I meant. I don't think of a PC as a Windows thing - I use Linux.

...R

Yeah, I know that's what you meant. But others may have been confused. Remember this commercial?

wait why cant i learn arduino C
i started pythone at code academy and finished 30%
ilike arduino C way more maybe because i use sensors
i am looking to connect a raspberry with an arduino and making a good project to send to google science fair

The newer versions of the Arduino IDE support, with custom flags, C++11 and of course you don't have to use the toolchain that comes with the Arduino IDE. With that in mind, the language to learn would be C++, not C.

You've mentioned "Arduino C" as though that is the name of a language, but to be clear there is no special version of C that runs on Arduino. Technically speaking, it isn't C or C++ that runs on Arduino but of course machine code that the ATMega processors can understand. It's all about the compiler you use and the version of GCC that comes with the Arduino IDE can compile C++ into machine code your Arduino can understand.

If you want your Arduino to communicate with your Raspberry Pi, you can do that with C++ running on both ends. However, depending on the complexity of the work that's being done on the Pi you may find it easier/better to use Python instead. For example, there is a simple serial library (pyserial) that makes it easy to interact with the Arduino over USB. From there, python has all kinds of libraries that make it easy to do things that would be tedious in C++ (even with libraries). For example, there are various web servers you can use, but my favorite is tornado, which is a great non-blocking, single-threaded web server.

now it all got clear to me
but what about C on the arduino end and python on the PI end would that work?
and what is the GCC ?

Yes, as I mentioned previously, C/C++ on Arduino and Python on Pi will work. GCC is the compiler the Arduino IDE uses. You have much learning to do!

For C++ this is a great site:

http://www.learncpp.com

Good luck!

well i love to learn haha hope to master the arduino and pi someday

Read about AVR GCC if really interested.
Master of 2 sets of hardware and software - could take a while. Jump in & get started!

aymanbreak:
but what about C on the arduino end and python on the PI end would that work?

Yes - that would be fine and a recommended way to do things - for most projects, it's more than adequate.

Something to keep in mind: The Raspberry Pi isn't a microcontroller - what it really is, is an SOC (system on a chip) - which is a very high density IC that (generally) combines a CPU, memory, video and audio (and other things) all on one chip - in essence, it is a complete computer (PC) on a chip. This chip is mounted on a carrier board, which has on it various physical interfaces (ethernet, audio, video, usb, etc) for connection to the outside world. In addition, there is (at least on the Pi) a set of GPIO (general purpose I/O) pins - to allow you to hook up other components. In that regard, it can act very much like a microcontroller, but in reality those pins aren't necessary for the system to be useful (whereas on a true microcontroller like the ATMega line - those pins are needed to add additional useful functionality).

aymanbreak:
and what is the GCC ?

GCC is the C/C++ compiler used by the Arduino IDE to turn your C/C++ code into the machine code the ATMega328 microcontroller on the Arduino can understand and run.

GCC, as a compiler and project, supports a wide range of various "targets" - that is, systems and cpu architectures - for which it can compile code for. The AVR line of microcontrollers is a family of targets, of which the ATMega328 is one.

GCC acts as a core component of the Arduino environment; the IDE itself (which is written and Java, and based on another IDE called Wiring - there is a bit of history there, if you want to follow up on it) takes your C/C++ code, then does some various translation and "wrapping" (the actual C/C++ code that is compiled is your code, combined with the various Arduino library(s) - plus a core main() function that calls the setup() and loop() functions in your code) - then it calls GCC to compile it; once compiled, another piece of software called "AVRDude" comes into play; it takes the machine code generated by GCC (a "hidden" .hex file) and interfaces with the bootloader on the Arduino hardware to upload the code to it.

It's actually a somewhat complex though very interesting "dance" the system goes through to get your code to the actual hardware; believe me, behind the scenes there is a lot happening that you likely are only dimly aware of - if you had to do it all by hand (which is, I might add, very possible - and actually can afford you greater control over a project, especially as scope and complexity of a project increases) - you would quickly become aware of just how much time and effort the Arduino IDE and environment saves you as a newbie.

That said - this hidden aspect of the system can be a crutch or a set of training wheels that can be hard to take off the bike - if my metaphor works (lol). In time, though, you can gradually study things, and come to understand how it all works together. At a certain point, you can even begin to hack on the Arduino libraries (the core one is the main one to play with). Why would you want to do that? Well, when you compile an Arduino sketch, the core library brings in a ton of cruft and extras that aren't really needed - but are included because a sketch is expected to be able to be compiled and run on a variety of different platforms. For instance, when a "digitalWrite()" occurs, there's actually a few if-then-else structures that a executed in the function - mainly to check for certain out-of-bounds conditions and other things based on the platform, as well as just to keep things "sane". If you know about these, and you know what you are doing (and your code is clean) - you can pull all of this stuff out (very, very carefully!) - and actually reduce the size of your compiled sketch, and increase the processing speed (because all of that extra cruft is gone). It's there for a very good reason, but if removed, it can make your code faster and leaner. Most people don't bother, though, because it's a huge task to strip everything down to only work with a single microcontroller - and if you want to move your project to a different microcontroller, your hacked library likely won't work with the new platform (and you'll have to redo all of that work again - or switch to the standard library).

Lastly - one other potential programming system you might want to investigate is called "Node.js" - it's basically javascript that runs "on the server" (instead of in your browser - though there are ways around that, too). It can bring a ton of flexibility (a big one is the ability to write one codebase that works both on the server and the browser - very useful for when you want to use the exact same validation logic in both places, for instance), and because it is javascript, it can be fairly easy to understand. There are various libraries and such for Node to communicate with an Arduino (via usb serial and other ways); Node.js can easily run on the Raspberry Pi (as a "server") - or on your laptop, or on a full-blown web server sitting in a rack at a colo facility. It's also becoming one of the premier ways to interface "internet of things" (IOT) devices. Just something to keep in mind...

cr0sh:
Yes - that would be fine and a recommended way to do things - for most projects, it's more than adequate.

Something to keep in mind: The Raspberry Pi isn't a microcontroller - what it really is, is an SOC (system on a chip) - which is a very high density IC that (generally) combines a CPU, memory, video and audio (and other things) all on one chip - in essence, it is a complete computer (PC) on a chip. This chip is mounted on a carrier board, which has on it various physical interfaces (ethernet, audio, video, usb, etc) for connection to the outside world. In addition, there is (at least on the Pi) a set of GPIO (general purpose I/O) pins - to allow you to hook up other components. In that regard, it can act very much like a microcontroller, but in reality those pins aren't necessary for the system to be useful (whereas on a true microcontroller like the ATMega line - those pins are needed to add additional useful functionality).

GCC is the C/C++ compiler used by the Arduino IDE to turn your C/C++ code into the machine code the ATMega328 microcontroller on the Arduino can understand and run.

GCC, as a compiler and project, supports a wide range of various "targets" - that is, systems and cpu architectures - for which it can compile code for. The AVR line of microcontrollers is a family of targets, of which the ATMega328 is one.

GCC acts as a core component of the Arduino environment; the IDE itself (which is written and Java, and based on another IDE called Wiring - there is a bit of history there, if you want to follow up on it) takes your C/C++ code, then does some various translation and "wrapping" (the actual C/C++ code that is compiled is your code, combined with the various Arduino library(s) - plus a core main() function that calls the setup() and loop() functions in your code) - then it calls GCC to compile it; once compiled, another piece of software called "AVRDude" comes into play; it takes the machine code generated by GCC (a "hidden" .hex file) and interfaces with the bootloader on the Arduino hardware to upload the code to it.

It's actually a somewhat complex though very interesting "dance" the system goes through to get your code to the actual hardware; believe me, behind the scenes there is a lot happening that you likely are only dimly aware of - if you had to do it all by hand (which is, I might add, very possible - and actually can afford you greater control over a project, especially as scope and complexity of a project increases) - you would quickly become aware of just how much time and effort the Arduino IDE and environment saves you as a newbie.

That said - this hidden aspect of the system can be a crutch or a set of training wheels that can be hard to take off the bike - if my metaphor works (lol). In time, though, you can gradually study things, and come to understand how it all works together. At a certain point, you can even begin to hack on the Arduino libraries (the core one is the main one to play with). Why would you want to do that? Well, when you compile an Arduino sketch, the core library brings in a ton of cruft and extras that aren't really needed - but are included because a sketch is expected to be able to be compiled and run on a variety of different platforms. For instance, when a "digitalWrite()" occurs, there's actually a few if-then-else structures that a executed in the function - mainly to check for certain out-of-bounds conditions and other things based on the platform, as well as just to keep things "sane". If you know about these, and you know what you are doing (and your code is clean) - you can pull all of this stuff out (very, very carefully!) - and actually reduce the size of your compiled sketch, and increase the processing speed (because all of that extra cruft is gone). It's there for a very good reason, but if removed, it can make your code faster and leaner. Most people don't bother, though, because it's a huge task to strip everything down to only work with a single microcontroller - and if you want to move your project to a different microcontroller, your hacked library likely won't work with the new platform (and you'll have to redo all of that work again - or switch to the standard library).

Lastly - one other potential programming system you might want to investigate is called "Node.js" - it's basically javascript that runs "on the server" (instead of in your browser - though there are ways around that, too). It can bring a ton of flexibility (a big one is the ability to write one codebase that works both on the server and the browser - very useful for when you want to use the exact same validation logic in both places, for instance), and because it is javascript, it can be fairly easy to understand. There are various libraries and such for Node to communicate with an Arduino (via usb serial and other ways); Node.js can easily run on the Raspberry Pi (as a "server") - or on your laptop, or on a full-blown web server sitting in a rack at a colo facility. It's also becoming one of the premier ways to interface "internet of things" (IOT) devices. Just something to keep in mind...

Baby steps, man, baby steps.

I just stumbled into this thread and just wanted to thank everyone for their thoughts and suggestions, I myself am "stuck" in between learning C++ for about a week, then fumbling back to learning Python, then back to C++, so it's been fun for sure but I think I'm going to throw my full effort into C++ then go to Python.