Operácie

Acrob002

Z SensorWiki

Verzia z 06:57, 12. jún 2010, ktorú vytvoril Balogh (diskusia | príspevky)

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 >