Categories
Sensors

Distance

Page 15

Software for the microcontroller

Arduino IoT Cloud: sketch tab

The microcontroller needs specific software to run with your sensor. The Arduino IoT Cloud provides a simple way of writing and uploading code to the microcontroller.

Move now to the Sketch tab of your project. The Arduino IoT Cloud has created the basic skeleton for your program (in Arduino terminology, a Sketch).

An Arduino sketch has by default two functions: setup and loop. The setup function runs only once, when the device is powered (see the Arduino reference for setup). The loop function runs constantly while the board is powered. The program starts at the opening curly bracket ({), runs all the commands and goes back to the first line to start over (see the Arduino reference for loop).

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

}

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

}

What comes next?

  1. for the Ultrasonic Ranger sensor, we need an specific library (and that implies a few steps)
  2. associate the sensor readings to the variable defined on Page 12

Continue to Page 16 – Ultrasonic Ranger Library.