Xiaoyuan Yu
/
smart_drawer
2*3 drawer
Diff: main.cpp
- Revision:
- 0:ef75cadf684d
--- /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); + } + } +}