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.
main.cpp
00001 #include "mbed.h" 00002 00003 Timer t; 00004 DigitalOut idle(LED1); 00005 DigitalOut busy(LED2); 00006 DigitalOut open(p10); 00007 InterruptIn start(p15); 00008 Serial pc(USBTX, USBRX); 00009 00010 int led=0; 00011 00012 void onfall() { 00013 pc.printf("Door Opened... "); 00014 t.start(); 00015 open=1; 00016 idle=0; 00017 led=1; 00018 } 00019 00020 void onrise() { 00021 t.stop(); 00022 open=0; 00023 pc.printf("Door Closed at %f\r\n", t.read()); 00024 t.reset(); 00025 busy=0; 00026 led=0; 00027 } 00028 00029 int main() { 00030 open=busy=idle=0; 00031 start.fall(&onfall); 00032 start.rise(&onrise); 00033 while(1) { 00034 if(led) { 00035 busy = !busy; 00036 } else { 00037 idle = !idle; 00038 } 00039 wait(1); 00040 } 00041 }
Generated on Tue Jul 12 2022 23:00:51 by
1.7.2