2*3 drawer

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Dennis_Yu
Date:
Fri Jul 20 02:19:49 2018 +0000
Commit message:
first commit

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	Fri Jul 20 02:19:49 2018 +0000
@@ -0,0 +1,66 @@
+#include "mbed.h"
+
+//DigitalOut myled(LED1);
+
+//DigitalOut(PB_3);
+//DIgitalOut(PB_12);
+
+//DigitalOut(PA_12);
+//DigitalOut(PA_11);
+//DigitalOut(PB_3);
+
+DigitalOut red[2]=
+{
+    PB_3,PB_12,
+};
+
+DigitalOut black[3]=
+{
+    PA_12,PA_11,PB_3,
+};
+
+
+/***************************************
+The SetUp function initial all pins. 
+****************************************/
+int SetUp()
+{
+    for(int i=0; i<2; i++)
+    {
+        red[i] = 0;
+    }
+    
+    for(int i=0; i<3; i++)
+    {
+        black[i] = 1;
+    }
+    
+    return 0;
+}
+
+/*****************************
+The Open function open a drawer at Row & Col.
+1 <= Row <= 2
+1 <= Col <= 3
+*****************************/       
+void Open(int Row, int Col)
+{
+    SetUp();
+    red[Row-1] = 1;
+    black[Col-1] = 0;
+    wait(0.1);
+    SetUp();
+}
+
+int main() 
+{
+    SetUp();
+    for(int col=1; col<=3; col++)
+    {
+        for(int row=1; row<=2; row++)
+        {
+            Open(row,col);
+            wait(0.5);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jul 20 02:19:49 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file