FRDM-KL25ZにDecoシールドを接続したときの制御サンプルです。

Dependencies:   TSI mbed

Files at this revision

API Documentation at this revision

Comitter:
kanpapa
Date:
Sun Mar 10 12:46:05 2013 +0000
Commit message:
1st version

Changed in this revision

TSI.lib Show annotated file Show diff for this revision Revisions of this file
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 a7a1bdb9cd50 TSI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Sun Mar 10 12:46:05 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/TSI/#507b1f67804b
diff -r 000000000000 -r a7a1bdb9cd50 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Mar 10 12:46:05 2013 +0000
@@ -0,0 +1,166 @@
+#include "mbed.h"
+#include "TSISensor.h"
+
+DigitalOut d0(D0);
+DigitalOut d1(D1);
+DigitalOut d2(D2);
+DigitalOut d3(D3);
+DigitalOut d4(D4);
+DigitalOut d5(D5);
+DigitalOut d6(D6);
+DigitalOut d7(D7);
+DigitalOut d8(D8);
+DigitalOut d9(D9);
+DigitalOut d10(D10);
+DigitalOut d11(D11);
+DigitalOut d12(D12);
+DigitalOut d13(D13);
+
+DigitalOut a0(A0);
+DigitalOut a1(A1);
+DigitalOut a2(A2);
+DigitalOut a3(A3);
+DigitalOut a4(A4);
+DigitalOut a5(A5);
+
+DigitalOut a6(PTE5);
+DigitalOut a7(PTE4);
+DigitalOut a8(PTE3);
+DigitalOut a9(PTE2);
+DigitalOut a10(PTB11);
+DigitalOut a11(PTB10);
+DigitalOut a12(PTB9);
+DigitalOut a13(PTB8);
+
+int main() {
+    TSISensor tsi;
+    
+    while (true) {
+        
+        int t = (int)(10.0 * tsi.readPercentage());
+        if ( t == 0 ) {
+            t = 30;
+        }
+        
+        // LED ON
+        d0 = 1;
+        wait_ms(t);
+        d1 = 1;
+        wait_ms(t);
+        d2 = 1;
+        wait_ms(t);
+        d3 = 1;
+        wait_ms(t);
+        d4 = 1;
+        wait_ms(t);
+        d5 = 1;
+        wait_ms(t);
+        d6 = 1;
+        wait_ms(t);
+        d7 = 1;
+        wait_ms(t);
+        d8 = 1;
+        wait_ms(t);
+        d9 = 1;
+        wait_ms(t);
+        d10 = 1;
+        wait_ms(t);
+        d11 = 1;
+        wait_ms(t);
+        d12 = 1;
+        wait_ms(t);
+        d13= 1;
+        wait_ms(t);
+                 
+        a13 = 1;
+        wait_ms(t);
+        a12 = 1;
+        wait_ms(t);
+        a11 = 1;
+        wait_ms(t);
+        a10 = 1;
+        wait_ms(t);
+        a9 = 1;
+        wait_ms(t);
+        a8 = 1;
+        wait_ms(t);
+        a7 = 1;
+        wait_ms(t);
+        a6 = 1;
+        wait_ms(t);
+
+        a0 = 1;
+        wait_ms(t);
+        a1 = 1;
+        wait_ms(t);
+        a2 = 1;
+        wait_ms(t);
+        a3 = 1;
+        wait_ms(t);
+        a4 = 1;
+        wait_ms(t);
+        a5 = 1;
+        wait_ms(t);
+        
+        // LED OFF
+        d0 = 0;
+        wait_ms(t);
+        d1 = 0;
+        wait_ms(t);
+        d2 = 0;
+        wait_ms(t);
+        d3 = 0;
+        wait_ms(t);
+        d4 = 0;
+        wait_ms(t);
+        d5 = 0;
+        wait_ms(t);
+        d6 = 0;
+        wait_ms(t);
+        d7 = 0;
+        wait_ms(t);
+        d8 = 0;
+        wait_ms(t);
+        d9 = 0;
+        wait_ms(t);
+        d10 = 0;
+        wait_ms(t);
+        d11 = 0;
+        wait_ms(t);
+        d12 = 0;
+        wait_ms(t);
+        d13 = 0;
+        wait_ms(t);
+
+        a13 = 0;
+        wait_ms(t);
+        a12 = 0;
+        wait_ms(t);
+        a11 = 0;
+        wait_ms(t);
+        a10 = 0;
+        wait_ms(t);
+        a9 = 0;
+        wait_ms(t);
+        a8 = 0;
+        wait_ms(t);
+        a7 = 0;
+        wait_ms(t);
+        a6 = 0;
+        wait_ms(t);
+
+        a0 = 0;
+        wait_ms(t);
+        a1 = 0;
+        wait_ms(t);
+        a2 = 0;
+        wait_ms(t);
+        a3 = 0;
+        wait_ms(t);
+        a4 = 0;
+        wait_ms(t);
+        a5 = 0;
+        wait_ms(t);
+
+    }
+}
diff -r 000000000000 -r a7a1bdb9cd50 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Mar 10 12:46:05 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b
\ No newline at end of file