Go Down

Topic: c#,c++,Perl, What is arduino's language? (Read 604 times) previous topic - next topic

napstercc

Hi,

Is there a book that shows how to program well and efficiently the arduino language like a c++ book?

Im learning c++, but what language is the arduino using? I cannot find any place that teaches how to learn the language in dept.

Please tell mehow the language works

Thank you

PaulS

Quote
Im learning c++

That's good, because that IS the language that the Arduinos are programmed in.

napstercc

Then why isn't working when I try the simplest c++ program?
#include <iostream>
using namespace std;
int main()

{
 
  int x;
 
  cout<<"Please enter value";
  cin>>x;
 
 

return 0;
}

Nick Gammon

It doesn't have a file system. There is no stdin and stdout.

Also the STL is not included. You can however download that (not that this gives you cout at such). However there *is* a streaming library. That lets you stream to the serial port.
http://www.gammon.com.au/electronics

PaulS

Quote
Then why isn't working when I try the simplest c++ program?

Have you LOOKED at your Arduino? Where do you expect the data that cout outputs to appear? The Arduino doesn't have a display device?

Where do you expect the data that cin is looking for to come from? Did your Arduino come with a keyboard attached?


magagna

Quote
Then why isn't working when I try the simplest c++ program?
#include <iostream>
using namespace std;
int main()
.
.
.


The Arduino environment defines main() for you already, so you can't redefine it. It's in hardware \ arduino \ cores \ arduino \ main.cpp and it looks like this:

Code: [Select]
#include <Arduino.h>

int main(void)
{
init();

#if defined(USBCON)
USB.attach();
#endif

setup();
   
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
       
return 0;
}



http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Go Up