homework_1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
tim65132006
Date:
Thu Mar 10 14:05:44 2016 +0000
Commit message:
03101005;

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
diff -r 000000000000 -r 5e39cd6c5291 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Mar 10 14:05:44 2016 +0000
@@ -0,0 +1,44 @@
+/*LAB_LED*/
+#include "mbed.h"
+
+//LED1 = D13 = PA_5 (LED on Nucleo board)
+
+DigitalOut led1(LED1);
+Ticker timer1;
+
+int a;
+
+void init_IO(void)
+{
+    a = 0;
+    led1 = 0;
+}
+
+void timer1_interrupt(void)
+{
+    a = a+1;
+}
+
+void init_TIMER(void)
+{
+    timer1.attach_us(&timer1_interrupt, 1000.0);//1ms interrupt period (1 KHz)
+}
+
+int main()
+{
+
+    init_IO();
+    init_TIMER();
+
+    while(1) {
+
+        if (a==500) {
+            led1 = 1;
+        }
+
+        if(a==1000) {
+            led1 = 0;
+            a = 0;
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 5e39cd6c5291 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Mar 10 14:05:44 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb
\ No newline at end of file