Operácie

Acrob002: Rozdiel medzi revíziami

Zo stránky SensorWiki

Balogh (diskusia | príspevky)
Balogh (diskusia | príspevky)
Bez shrnutí editace
Riadok 1: Riadok 1:
== Hello, World! ==
== Hello, World! ==
[[Obrázok:ArduinoIDE01.png|right]]


Here is a source code for Your first program.
Here is a source code for Your first program.
Riadok 15: Riadok 18:
</source>
</source>


It should look like on the following screen
It should look like on the screen right.


[[Obrázok:ArduinoIDE01.png|center]]


To run the program on Your board it is necessary to compile and download the program using the [[Obrázok:ArduinoButtonUpload.png|29px]] button.
To run the program on Your board it is necessary to compile and download the program using the [[Obrázok:ArduinoButtonUpload.png|29px]] button.

Verzia z 07:00, 12. jún 2010

Hello, World!

Here is a source code for Your first program.

void setup()
{
 Serial.begin(9600);
}

void loop()
{
 Serial.println("Hello, World!");
}

It should look like on the screen right.


To run the program on Your board it is necessary to compile and download the program using the button. If the operation was successfull, the downloaded program runs automatically. To see how it works, it is necessary to open an additional window with the terminal . It should look like this:

How it works

Notice that program contains two blocks. Section setup() runs just once, during the startup. Usually contains settings, definitions and hardware initialization and configuration commands.

Then the program performs an infinity loop(). There is defined the whole operation of Your program.

  • Why there is not just single Hello, World! message?

This is because the print command is located in the loop() section.

  • But I want to have just ONE message!

Well, why not. You can
 a) place the print command into the setup() section and leave the loop() empty.
 b) stop the loop using e.g following construction:

void loop()
{
 Serial.println("Hello, World!");
 for(;;)  /* stop here */
}

IDE description

If You just want to verify Your program, You can just compile it without downloading to Your board.

Don't forget to save Your work often using the button.


< Previous | Home | Next >