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:59b7da6bb864, committed 2015-05-28
- Comitter:
- Jamess
- Date:
- Thu May 28 18:05:21 2015 +0000
- Commit message:
- First Example in how to use state machines in c. Using if|else;
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 May 28 18:05:21 2015 +0000
@@ -0,0 +1,58 @@
+/*****************************************************************/
+/* How to use State Machines in C */
+/* If | Else */
+/*****************************************************************/
+
+//Librarys:
+#include "mbed.h"
+
+//Outputs:
+DigitalOut red(LED1);
+DigitalOut green(LED2);
+DigitalOut blue(LED3);
+
+//Functions:
+
+int main() {
+
+/**************VARIABLES**************/
+ enum states{
+ LED_GREEN,
+ LED_BLUE,
+ LED_RED
+ };
+ enum states state = LED_GREEN;
+
+/***************ESTADOS***************/
+
+while(1){
+ if (state == LED_GREEN){
+
+ green=1;
+ blue=0;
+ red=0;
+ state = LED_BLUE;
+ wait(1);
+
+ }else if(state == LED_BLUE){
+
+ green=0;
+ blue=1;
+ red=0;
+ state = LED_RED;
+ wait(1);
+
+ }else if(state == LED_RED){
+
+ green=0;
+ blue=0;
+ red=1;
+ state = LED_GREEN;
+ wait(1);
+
+ }
+
+}//end of while
+}//end of main
+
+/************************************/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 28 18:05:21 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/cbbeb26dbd92 \ No newline at end of file