Pages: [1] 2   Go Down
Author Topic: Wich programing language to learn  (Read 6517 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guyz, i'm new to programing and i've started to learn c++, now my question would be am i doing it the right way? Is it best to learn c++ and then start doing arduino programing, asking as eventualy i want to be able to write a program that has a user interface wich controls arduino depending on the user input.

Will C++ knowledge help me understand all about programing behind the hardware or would i would be better of to learn C. Just a sidenote, i want to be able to progress to more powerful hardware with time so looking for best programing language to achive that.

Much abliged
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24325
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can learn C++ by programming Arduino.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Belgium
Offline Offline
Edison Member
*
Karma: 58
Posts: 1731
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Dadorcp
Just a sidenote, i want to be able to progress to more powerful hardware with time so looking for best programing language to achive that.
First of all: I think there is no correct place to ask this question. As this is a arduino forum which is C++ oriented the answer here is C++ is a good start.
Go to a Bascom place and they will tell you bascom is a great start; go to a java place ....

As I have a pretty wide background I'll do an effort anyway:
As you are talking about "more powerful hardware" development and micro controller development at the same time I would say C++ (as a language and not as 'my first language') is the only qualifying language.
As far as I know C++ is the only language that has great support on PC/unix/linux -so not application servers;mainframes- and micro controller code development. You willing have to go with proprietary software for the PC part though (read pay license or use trial version of some kind).
Note that -even though you can use the same language- "more powerful hardware" development is majorly different from micro controller development.
This because languages are moving away from the underlying hardware to a higher level of programming closer to "business needs". Whereas on a micro controller you need full understanding of the hardware.

i want to be able to write a program that has a user interface wich controls arduino depending on the user input.
You need a way to communicate between the system that runs you user interface and your arduino. There is only a limited number of integrations.
The once I know are: serial; ethernet; bluetooth; xbee
Only serial is a protocol where C++ can be high on the list of advised languages. IMHO serial is mostly used but (because arduino IDE and serial monitor use it) but is IMHO hardly a preferred choice to put a GUI on top of Arduino.

Conclusion:
For what you want to do you can go with C++ only but it will be far more beneficial and productive to learn more than one language.
The languages to learn will be dependent on the project and tool chain you have in mind.

Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you guyz for helping me out, i'm quite blury when it comes to this, thats becouse i dont have the big picture of how its all connected to eachother, software, languages, hardware(readymade souch arduino and alike), and electronics ofc.

Reason why your input is of souch importance to me before i go and learn stuff is, i'm acquainted enough to know learning this stuff is never ending process, so better start with right stuff.

Just to make it clear, i didn't ment to say that arduino is not powerful, merly that i would like to become quite a knowledgable person so i can work with more hardware platforms depending on what i need.

For instance, i was told that arduino can do anything you want, but when useing 2 arduino serial connection over longer distance ethernet cable, it is not recommended to use arduino base for video streaming onto small display (for this matter, handheld controller with display, no aditional computer). Not enough speed/memory or something like that, and thats something i really need for my ultimate project one day, but theres no rush, get my basics straight and slowly work my way up.

Also, i'm certantly gonna learn more languages, even from my beginer perspective it was obvious to me that this aint gonna happen if i learn just one thing and now when you advised me to learn more than one, i'm gonna do just that.

Again, thank you so much for helping me out.

Regards

« Last Edit: September 23, 2012, 08:44:02 am by Dadorcp » Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 23
Posts: 1759
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, The Arduino IDE and Arduino's subset of C/C++ is a good place to start.

Main thing is, DO it.  After time it will all make sense and you will learn more than one language, especially if you end up writing Web stuff also.

READ other people's code. The EXAMPLES that come with Arduino (Click on FILE, hover over EXAMPLES) are good.

I have code examples up for a magazine article I wrote recently. Maybe look at the Template I start with:
http://arduino-info.wikispaces.com/SHED-Article2SOFTWARE-SketchTemplate

and here's a simple example of an automatic system:
http://arduino-info.wikispaces.com/SHED-Article2SOFTWARE+-+Automation+Example

That makes the point that thinking through the Structure of a program is as important as the code. With Arduino I like to think of every nontrivial program as doing these 3 things:

  ReadSensors();
  MakeDecisions();
  TakeActions();

Those 3 things sort of happen (conceptually) from right to left on the diagram here:
http://arduino-info.wikispaces.com/StarterSet-Circuits-Pins-Bits

just add details for whatever you want to accomplish  smiley

I'll be finishing a rewrite of the whole Arduino How-To this week and you'll find it on the ArduinoInfo WIKI here - http://arduinoinfo.info

Let us know what you think after getting started. And I'd like to hear about whatever you initially found confusing. terry@yourduino.com
« Last Edit: September 23, 2012, 10:02:11 am by terryking228 » Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24325
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
and here's a simple example of an automatic system
Simple maybe, but it is fairly well packed with bad programming; globals that don't need to be and variables initialised in setup, when they might just as well have been initialized when declared, and an assignment in an "if".
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
it is fairly well packed with bad programming
I don't think so. IMHO it can be improved, but it has also good points.

I don't see any "globals the shouldn't be". Could you elaborate on that ?

I like the general structure (which is the main point of the example, IMHO). Read inputs, set internal state based on input values and previous state, drive outputs based on the newly calculated internal state.

The assignment inside if() is a bad error, indeed. But we all know it can come up as a typo.

MakeDecisions() is missing IMHO a hysteresis threshold.
Code:
void MakeDecisions()
{
    if (photoValue > potValue + thresh)
    {   
        lightsOn = true;   
    }
    else if (photoValue < potValue - thresh)
    {   
        lightsOn = false;
    }
}

I would also rename showValues as debugMode, but that's just a matter of personal taste.

Finally, I don't like that delay(1000) in loop(). I would replace that with the usual "blink without delay" technique. But maybe the author didn't want to increase the complexity of the example.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24325
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I don't see any "globals the shouldn't be". Could you elaborate on that ?
There are four globals.
Only the debug print flag should be, the rest should be passed to and returned from functions, otherwise it looks like we haven't progressed past BASIC.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 169
Posts: 12446
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


There are free readers with code examples which might help "to learn by example"
e.g. - http://www.earthshineelectronics.com/files/ASKManualRev5.pdf -

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16516
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I don't see any "globals the shouldn't be". Could you elaborate on that ?
There are four globals.
Only the debug print flag should be, the rest should be passed to and returned from functions, otherwise it looks like we haven't progressed past BASIC.


Hey, your not the boss of my globals.  smiley-wink
Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 23
Posts: 1759
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Guys,

I am remembering something I once wrote that included the phrase "Egoless Programming"  smiley-razz

Very valid criticisms of "Good programming Techniques", and I certainly didn't follow some in the desire to Keep It Simple.

Globals: I wanted to have the Newbie at least see and understand VARIABLES.  TYPES, OMG...

delay: Again in the interest of simplicity.. Non-blocking code is a great subject for a later excercise.

I will change the assignment inside the if: You're right, and it will actually be clearer.  

@tuxduino, I LIKE that example of using hysteresis, and I'll steal that for a later example.

Variable initialization in the declaration may be a good standard, but it's not obvious to the Newbie. I was trying to make it clear What Goes Where.

Quote
There are free readers with code examples which might help "to learn by example"
e.g. - http://www.earthshineelectronics.com/files/ASKManualRev5.pdf -
Mike McRoberts has done some excellent work for sure, and I recomment his book "Starting Arduino" to many people.

In the spirit of Niklaus Wirth,  and "Stepwise Refinement", I will look at several incarnations of this simple example, incorporating those better programming techniques and WHY they matter.  (I'd have loved it if Arduino had started off with PASCAL as a base).

BASIC was structurally inadequate, but it could be CLEAR to the newbie.  My kids learned to program in Dartmouth BASIC on the phone line, starting in 1972.  These days, my wife is the head librarian at Hanover High School, 1/2 a mile from Kurtz and Kemeny's old offices where they developed it in 1964.

I'd be really interested in ideas you 'young' guys have about presenting each of these CS concepts to the almost-newbie.  I don't want to start by showing them the guts of one of Rob's libraries in C++ and have them turn to watching the Destructors on TV football  smiley

« Last Edit: September 23, 2012, 02:54:19 pm by terryking228 » Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 23
Posts: 1759
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

..On Second Thought: What's Bad aboot this??

  if (photoValue > potValue)
  {   
    lightsOn = true;   
  }
  else
  {   
    lightsOn = false;
  }
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I don't see any "globals the shouldn't be". Could you elaborate on that ?
There are four globals.
Only the debug print flag should be, the rest should be passed to and returned from functions, otherwise it looks like we haven't progressed past BASIC.

I think you didn't understand the concept behind that code. The debug print flag is a state variable as all the others are. Just as an object methods freely access its data members without having them passed as arguments, so in that example the three main program entry points act directly on program state variables.

Of course this is just my opinion.

I'd be interested in seeing how you'd modify the sketch to make it global-less, as you have just described. Thanks.
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

..On Second Thought: What's Bad aboot this??

  if (photoValue > potValue)
  {   
    lightsOn = true;   
  }
  else
  {   
    lightsOn = false;
  }

You're comparing two analog values, which could fluctuate by some units. If the test is done "fast", you can have flickering.
In fact your 1s delay between each run prevents this from happening even if you haven't any hysteresis.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24325
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I think you didn't understand the concept behind that code.
You are, of course, entitled to your opinion, but I believe, with any due respect that I do understand the concept.

I'm a very good 7000km from my laptop at the moment, so I'm not going to be editing any code on an 18cm tablet screen, sorry.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1] 2   Go Up
Jump to: