Connect with us

Question concerning Arduino and C++

Discussion in 'Microcontrollers, Programming and IoT' started by HellasTechn, Feb 11, 2020.

Scroll to continue with content
  1. HellasTechn

    HellasTechn

    1,524
    212
    Apr 14, 2013
    Hello friends.
    I am new to programing and microcontrollers in general. I had no knowledge of C language until I recently found some very useful YouTube lessons about C language and how to build a small program on PC with it. After watching the lessons i managed to understand the very basic concepts of the language (what is a variable, an array, a function etc). I bought an arduino uno and a mega board and I started playing with them. I have come to realize that I need not only C language but also C++. I found C++ lessons again aimed for pc programming and I have to admit that it is very very hard for me to understand what is going on. I intend to watch all the lessons and then move to practice C++ on the arduino. So could anyone suggest me which parts of the C++ language concerning the arduino should I focus after finishing the lessons ?

    Thank you !
     
  2. Bluejets

    Bluejets

    4,046
    844
    Oct 5, 2014
    You do realise it is not necessary to know C or C++ to program Arduino.

    There is a much bore basic approach and for the most part will get you to the same end in a much easier shorter time.
     
  3. bertus

    bertus Moderator

    669
    234
    Nov 8, 2019
    HellasTechn likes this.
  4. HellasTechn

    HellasTechn

    1,524
    212
    Apr 14, 2013
    Actually i had no idea that one can program an arduino without C or C++. Could you explain more please ?
     
  5. Harald Kapp

    Harald Kapp Moderator Moderator

    10,025
    2,138
    Nov 17, 2011
    Which approach do you mean?

    Constantin, you could use assembler. Although I will not recommend this as a starting point. An arduino sketch is a program based on C/C++. The language may seem to be more difficult to learnd than say e.g. Basic, but is rather hardware-near and thus well suited for embedded programming. For your first starter programs you will have little contact with the C++ side of a sketch. This will become more and more relevant once you start using classes from libraries or even write your own classes.
    My tip: Do not dive too deep into general C++ programming literature as it will present you with examples and code that are mainly relevant for PC programming, not for embedded programming. Concentrate on arduino-specific literature instead. Tutorials and sample programs can be found by the dozen on the internet.
     
    hevans1944 and HellasTechn like this.
  6. HellasTechn

    HellasTechn

    1,524
    212
    Apr 14, 2013
    Yes, that's exactly my point Harald. Though in my opinion finding tutorials that are easy to understand by a complete newbie is not very easy. Thats why i think it would be better to finish the lessons ive downloaded first.
     
    Last edited: Feb 11, 2020
  7. HellasTechn

    HellasTechn

    1,524
    212
    Apr 14, 2013
    The last lesson i watched today was about (classes and arrays) also (classes and const) not to mention the last one that was about classes, arrays and pointers combined...
    Total brain burnout for me :confused:

    And im not even close to hearning inheritance.
     
  8. Bluejets

    Bluejets

    4,046
    844
    Oct 5, 2014
    Go to the Arduino page, download and install the IDE, run down the list of example sketches and you'll soon see.
    From the above I think you are trying to jump in at the deep end.
    Start simpler......
    Best to get a couple of boards etc. to play with as you'll pick it up more quickly.
    Using clone boards from China is a way of doing it much more economically and they work just fine.
    There is an excellent support forum to answer your question also. Just remember to include as much info as possible.

    https://www.arduino.cc/en/main/software

    Watching some videos also helps.

    Jeremy Blum ..... https://www.youtube.com/results?search_query=jeremy+blum+arduino

    Ralph Bacon ...... https://www.youtube.com/channel/UC8Ob-HnnmhlgSv5Vs_i32TQ/videos

    Julian Ilett ............https://www.youtube.com/user/julius256/videos
     
    HellasTechn likes this.
  9. HellasTechn

    HellasTechn

    1,524
    212
    Apr 14, 2013
    I have already purchased an uno and a mega board (both clones) i love the mega board because it also comes in small form factor plus it has bigger memmory and 4 UART's. I have been working on a small project of mine that involves GPS receiver where the mega board reads the serial stream from, stores it in a char array and does some calculations. It took me 8 months to complete with lots of help from arduino forum.
    What drives me to learn C++ is the fact that all serius programs ive seen online (from github for example) use C++ and i really dont understand a single line. Even my code uses a little C++ (booleans for example).
     
  10. Bluejets

    Bluejets

    4,046
    844
    Oct 5, 2014
    Yes, I understand exactly where you are coming from.
    Most of my applications, although variable in nature, usually are a combination of many different operations.
    Most are covered quite well by the Arduino pro mini.
    I tend to learn as I go, so to speak, where I don't bother too much with a wide knowledge base, rather, apply each section as I have a use for it.
    I think many operate in a similar manner.
    This is one of my commercial designs.
     

    Attached Files:

    JWHassler and HellasTechn like this.
  11. HellasTechn

    HellasTechn

    1,524
    212
    Apr 14, 2013
    Neat design ! Congrats. I have a few pics of my own project to share with you. Still i would like to learn the basics of C++ to be able to put them to use in the future.

    Pic 1 and 2 are the PCB's
    Pic 3 is an smd chip being tested by me soldered on a custom adapter board for the breadboard.
    Pic 4,5,6 are all the boards "sandwitched" together to minimize space and eliminate the need for extra wires.
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      346 KB
      Views:
      12
    • 2.jpg
      2.jpg
      File size:
      396.5 KB
      Views:
      11
    • 5.jpg
      5.jpg
      File size:
      195.1 KB
      Views:
      12
    • 6.jpg
      6.jpg
      File size:
      197.6 KB
      Views:
      13
    • 3.jpg
      3.jpg
      File size:
      280.5 KB
      Views:
      10
    • 4.jpg
      4.jpg
      File size:
      294 KB
      Views:
      10
    Last edited: Feb 12, 2020
  12. Harald Kapp

    Harald Kapp Moderator Moderator

    10,025
    2,138
    Nov 17, 2011
    Do you have any specific questions?
    Apart from the object oriented extensions C++ is very much like C. As a matter of fact, when C++ was created it was, as far as I know, first only a preprocessor to convert C++ code into ordinary C code.
     
  13. HellasTechn

    HellasTechn

    1,524
    212
    Apr 14, 2013
    Well like in post 1, i dont have a specific question just general advices if someone knew which parts (that apply to pc's) i should not pay too much attention.
     
  14. Bluejets

    Bluejets

    4,046
    844
    Oct 5, 2014
    Good work on the pcb's.
    A little bit of undercut but not bad all the same.
    I tend to use a protective spray after the board is completed.
    If it looks like it will be more than a couple of hours exposed, I spray it and the product below allows one to "solder through" later.
    https://www.jaycar.com.au/circuit-board-lacquer-spray-can/p/NA1002

    Boards in my pics came from Chinese pcb maker @5 for $2.00. ( postage was $35 but it made the job considering it was for commercial)
     

    Attached Files:

    HellasTechn likes this.
  15. HellasTechn

    HellasTechn

    1,524
    212
    Apr 14, 2013
    Yes i know of these kind of spray. I use it some times. It is really nice :)

    Thanks :).

    Tinning was done with the solder iron, thats why it looks uneven but the traces are all solid :)
     
  16. Nanren888

    Nanren888

    246
    49
    Nov 8, 2015
    I guess my only additional comment that I did not notice made goes like this.
    C++ is different. It is object oriented.
    It is possible and often done to programme C language things in C++ syntax.
    But, the strength of the language over C is objects.
    You might want to find some tutorials on object oriented programming (using C++) to get clear on the change in ways to do things.
    Apologies if stated above that I didn't notice.
     
  17. HellasTechn

    HellasTechn

    1,524
    212
    Apr 14, 2013
    And vice versa.

    You are right. Actually i am begining to understand the major differences between procedual programming and object orieted. My doubt is which parts (C++) only concern Computer programming and do not concern micro controller programming so that i can focus on micro controllers.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-