Richard McWilliam
/
tilt
This program senses the status of a tilt switch using the MBED LPC1768
Revision 0:bce3540c3f6f, committed 2015-06-29
- Comitter:
- rmcwilliam101
- Date:
- Mon Jun 29 12:26:37 2015 +0000
- Commit message:
- This program senses the status of a tilt switch circuit
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 bce3540c3f6f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jun 29 12:26:37 2015 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" +/* This program generates a tilt alarm using LED1 */ + +/* Define some useful constants */ +#define ON 1 +#define OFF 0 +#define HIGH 1 +#define LOW 0 + +/* Use LED1 */ +DigitalOut light1(LED1); +/* Use pin 5 for the tilt sensor */ +DigitalIn tilt_sens(p5); + +/* Main loop */ +int main() +{ + while(1) + { + /* Set LED1 depending upon the current status of the tilt sensor */ + if (tilt_sens == HIGH) + { + light1=ON; /* Tilt alarm LED is ON */ + } + if (tilt_sens == LOW) + { + light1=OFF; /* Tilt alarm LED is OFF */ + } + wait(0.3); /* Wait 0.3 seconds */ + } +} +
diff -r 000000000000 -r bce3540c3f6f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jun 29 12:26:37 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7 \ No newline at end of file