Operácie

Acrob002: Rozdiel medzi revíziami

Z SensorWiki

(How it works)
Riadok 1: Riadok 1:
 
 
== Hello, World! ==
 
== Hello, World! ==
  
Riadok 32: Riadok 31:
 
Then the program performs an infinity <TT>loop()</TT>. There is defined the whole operation of Your program.
 
Then the program performs an infinity <TT>loop()</TT>. There is defined the whole operation of Your program.
  
Why there is not just single Hello, World! message?
+
* '''Why there is not just single Hello, World! message?'''
  
 
This is because the print command is located in the <TT>loop()</TT> section.
 
This is because the print command is located in the <TT>loop()</TT> section.
  
But I want to have just ONE message!
+
* '''But I want to have just ONE message!'''
  
 
You can  
 
You can  

Verzia zo dňa a času 06:58, 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 following screen

ArduinoIDE01.png

To run the program on Your board it is necessary to compile and download the program using the ArduinoButtonUpload.png 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 ArduinoButtonTerminal.png. It should look like this:

ArduinoIDE02.png

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!

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 ArduinoButtonCompile.png without downloading to Your board.

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


< Previous | Home | Next >