Energia

Examples > Basics

### Bare Minimum code needed to get started

This example contains the bare minimum of code you need for an Energia sketch to compile: the setup() method and the loop() method.

### Hardware Required

- LaunchPad Board

### Relevant groundwork

None

### Circuit

Only your LaunchPad Board is needed for this example.

image developed using Fritzing. For more circuit examples, see the Fritzing project page.

### Schematic

### Code Explanation

The setup() function is called when a sketch starts. Use it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each powerup or reset of the LaunchPad board.

After creating a setup() function, the loop() function does precisely what its name suggests, and loops consecutively, allowing your program to change and respond as it runs. Code in the loop() section of your sketch is used to actively control the LaunchPad board. The code below won't actually do anything, but it's structure is useful for copying and pasting to get you started on any sketch of your own. It also shows you how to make comments in your code.

Any line that starts with two slashes (//) will not be read by the compiler, so you can write anything you want after it. Commenting your code like this can be particularly helpful in explaining, both to yourself and others, how your program functions step by step.

### Code

    void setup() {
      // put your setup code here, to run once:
    }

    void loop() {
      // put your main code here, to run repeatedly:
    }

### Working Video

(Insert Video Here)

### Try it out:

- compile a blank sketch, then add the bare minimum code

See Also

- setup()
- loop()

Getting Started Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Energia reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Energia reference is based on the Arduino reference. Code samples in the reference are released into the public domain.

©Energia | Edit Page | Page History | Printable View | All Recent Site Changes