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.
Revision 0:a4f5053c990a, committed 2015-09-24
- Comitter:
- noutram
- Date:
- Thu Sep 24 12:28:50 2015 +0000
- Child:
- 1:9f488d81a54a
- Commit message:
- Initial version 24-09-2015
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Sep 24 12:28:50 2015 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#define kRED 4
+#define kYELLOW 2
+#define kGREEN 1
+
+
+//Global objects
+BusOut binaryOutput(D5, D6, D7);
+
+DigitalIn SW1(D3);
+DigitalIn SW2(D4);
+
+AnalogIn AIN(A0);
+float fVin = 0.0;
+
+//Main function
+int main() {
+
+
+ while(1) {
+
+ //Read ADC
+ fVin = AIN;
+
+ //Write to terminal
+ //3 decimal places, fieldwidth=5
+ printf("Analog input = %6.4f\n", fVin);
+
+ if (fVin < 0.4f) {
+ binaryOutput = kGREEN;
+ } else if (fVin < 0.6f) {
+ binaryOutput = kYELLOW;
+ } else {
+ binaryOutput = kRED;
+ }
+
+ //Wait
+ wait(0.1);
+
+ } //end while(1)
+} //end main
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Sep 24 12:28:50 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/bad568076d81 \ No newline at end of file