Richard McWilliam
/
tilt
This program senses the status of a tilt switch using the MBED LPC1768
main.cpp
- Committer:
- rmcwilliam101
- Date:
- 2015-06-29
- Revision:
- 0:bce3540c3f6f
File content as of revision 0:bce3540c3f6f:
#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 */ } }