Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HeaderTest by
Diff: main.cpp
- Revision:
- 1:362abfaa2a27
- Parent:
- 0:cc014c610423
--- a/main.cpp Thu Oct 19 21:05:11 2017 +0000
+++ b/main.cpp Fri Oct 20 01:22:53 2017 +0000
@@ -1,10 +1,10 @@
/*
- Project: HeaderTest
+ Project: NoHeaderTest
File: main.cpp
Last revised by: Dr. C. S. Tritt
Last revision on: 9/19/17 (v. 1.0)
- Repeatedly toggles on-board LED.
+ Repeatedly toggles on-board LED. Demonstrates single file project approach.
This example code is in the public domain.
*/
@@ -13,14 +13,15 @@
// must also be added to the project either by importing it or by "Fixing" the
// error that is generated when it has not been imported.
#include "mbed.h"
-// Use this type of #include to include your own custom header files. Typically
-// 1 per project or library.
-#include <myProj.h>
+
// Mbed driver class objects are typically declared and defined as global.
DigitalOut board_LED(LED1);
-// Define global variables here.
+
const float BASE_WAIT = 0.1;
int cycles = 1;
+
+void myStuff(void); // Declared here, defined after main.
+
/* The "main" function defines your main program -- it executes as soon as
you program the board.
*/
@@ -32,4 +33,10 @@
cycles = 1;
}
}
+}
+
+void myStuff(void) {
+ board_LED = !board_LED; // Toggle LED state.
+ wait(BASE_WAIT * (float) cycles); // Wait varying intervals.
+ cycles++; // Slowly slow down flash rate.
}
\ No newline at end of file
