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:159abf0f8d1c, committed 2015-02-26
- Comitter:
 - audreyhernandez
 - Date:
 - Thu Feb 26 19:02:21 2015 +0000
 - Commit message:
 - Source code for RelayTimer.cpp
 
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 Feb 26 19:02:21 2015 +0000
@@ -0,0 +1,79 @@
+#include "mbed.h"
+ 
+#define IOS1 (0x100) // PA_8
+#define IOS2 (0x40) // PA_6
+#define IOS3 (0x80) // PA_7
+#define RGB (0x200) // PA_9
+
+Timer timer;
+Serial pc(SERIAL_TX, SERIAL_RX);
+DigitalIn button(USER_BUTTON);
+PortOut GPIO1 (PortA, IOS1);
+PortOut GPIO2 (PortA, IOS2);
+PortOut GPIO3 (PortA, IOS3);
+PortOut cLED (PortA, RGB);
+DigitalOut LED(LED1);
+int currentTime;
+bool latch;
+ 
+int main()
+{
+  latch = false;
+  while(1)
+  {
+      // check button if pressed start timer and latch in.
+      if ((button == 0) && (latch == false))
+      {
+            timer.reset();
+            timer.start();
+            latch = true;          
+      }
+      
+      if (latch == true)
+      {
+          LED = 1;
+          currentTime = timer.read_ms();
+          //pc.printf("TIMER IS AT %d \n\r", currentTime);
+          //wait(1);
+          
+          // set GPIO1 state
+          if ((currentTime >= 0) && (currentTime < 10000))
+          {
+              GPIO1 = IOS1;
+              cLED = RGB;
+          }
+          else
+          {
+              GPIO1 = 0;  
+          }
+          
+          // set GPIO2 state
+          if ((currentTime >= 3000) && (currentTime < 13000))
+          {
+              GPIO2 = IOS2;
+          }
+          else
+          {
+              GPIO2 = 0;   
+          }
+          
+          // set GPIO3 state
+          if ((currentTime >= 12000) && (currentTime < 22000))
+          {
+              GPIO3 = IOS3;
+          }
+          else
+          {
+              GPIO3 = 0;   
+          }
+          
+          // check if sequence is over, stop timer and reset latch.
+          if (currentTime > 22000)
+          {
+              latch = false;
+              LED = 0;
+              timer.stop();
+          }
+      }
+  }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Feb 26 19:02:21 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6213f644d804 \ No newline at end of file