Program structure
The structure of the ".pde" codes is divided into 2 basic functions: setup() and loop(). The setup() is the first part of the code, which is only run once when the code is initialized (or Waspmote is reset). In this part it is recommendable to include the initialization of the modules which are going to be used, as well as the part of the code which is only important when Waspmote is started.
On the other hand, the loop() function runs continuously, forming an infinite loop. The goal of this function is to measure, send the information and save energy by entering a low consumption state.
The program skeleton:
1
// 1. Include Libraries
2
// 2. Definitions
3
// 3. Global variables declaration
4
5
void setup()
6
{
7
// 4. Modules initialization
8
}
9
10
void loop()
11
{
12
// 5. Measure
13
// 6. Send information
14
// 7. Sleep Waspmote
15
}
Copied!
And just take a look to our hundreds of examples. They try to show a certain order.
Copy link