June 2018
Beginner to intermediate
280 pages
6h 58m
English
The following Energia code for Launchpad reads values from the ultrasound sensor and monitors the values through a serial port.
The following code defines the pins in Launchpad to handle ultrasonic echo and trigger pins and also defines variables for the duration of the pulse and the distance in centimeters:
const int echo = 9, Trig = 10; long duration, cm;
The following code snippet is the setup() function. The setup() function is called when the program starts. Use this to initialize variables, pin modes, to start using libraries, and so on. The setup function will only run once, after each power up or reset of the Launchpad board. Inside setup(), we initialize serial communication with a baud rate ...