Demonstrates use of header files and compilation units (files) for each function.

Dependencies:   mbed

Committer:
CSTritt
Date:
Thu Oct 19 21:05:11 2017 +0000
Revision:
0:cc014c610423
Initial version. Demonstrates use of header files and compilation units (files) for each function.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
CSTritt 0:cc014c610423 1 /*
CSTritt 0:cc014c610423 2 Project: HeaderTest
CSTritt 0:cc014c610423 3 File: main.cpp
CSTritt 0:cc014c610423 4 Last revised by: Dr. C. S. Tritt
CSTritt 0:cc014c610423 5 Last revision on: 9/19/17 (v. 1.0)
CSTritt 0:cc014c610423 6
CSTritt 0:cc014c610423 7 Repeatedly toggles on-board LED.
CSTritt 0:cc014c610423 8
CSTritt 0:cc014c610423 9 This example code is in the public domain.
CSTritt 0:cc014c610423 10 */
CSTritt 0:cc014c610423 11 // Use #include directives to "paste" text from other files into your code.
CSTritt 0:cc014c610423 12 // Use this #include to declare all the mbed driver classes. The mbed library
CSTritt 0:cc014c610423 13 // must also be added to the project either by importing it or by "Fixing" the
CSTritt 0:cc014c610423 14 // error that is generated when it has not been imported.
CSTritt 0:cc014c610423 15 #include "mbed.h"
CSTritt 0:cc014c610423 16 // Use this type of #include to include your own custom header files. Typically
CSTritt 0:cc014c610423 17 // 1 per project or library.
CSTritt 0:cc014c610423 18 #include <myProj.h>
CSTritt 0:cc014c610423 19 // Mbed driver class objects are typically declared and defined as global.
CSTritt 0:cc014c610423 20 DigitalOut board_LED(LED1);
CSTritt 0:cc014c610423 21 // Define global variables here.
CSTritt 0:cc014c610423 22 const float BASE_WAIT = 0.1;
CSTritt 0:cc014c610423 23 int cycles = 1;
CSTritt 0:cc014c610423 24 /* The "main" function defines your main program -- it executes as soon as
CSTritt 0:cc014c610423 25 you program the board.
CSTritt 0:cc014c610423 26 */
CSTritt 0:cc014c610423 27 int main() { // This curly brace marks the beginning of the main function.
CSTritt 0:cc014c610423 28 board_LED = 0; // Initialize LED state (not necessary in this case).
CSTritt 0:cc014c610423 29 while(true) { // while(true) repeat forever.
CSTritt 0:cc014c610423 30 myStuff(); // Call function that is in its own file.
CSTritt 0:cc014c610423 31 if (cycles == 11) { // Reset cycles after 10 of them.
CSTritt 0:cc014c610423 32 cycles = 1;
CSTritt 0:cc014c610423 33 }
CSTritt 0:cc014c610423 34 }
CSTritt 0:cc014c610423 35 }