Generic function for configuring the register
Dependencies: MMA8451Q8 SLCD mbed
Fork of KL46z_single_tap_empty by
main.cpp
- Committer:
- scohennm
- Date:
- 2015-01-26
- Revision:
- 1:65b0e488f02a
- Parent:
- 0:912303e63cbd
- Child:
- 2:17a0550771c4
File content as of revision 1:65b0e488f02a:
#include "mbed.h" #include "SLCD.h" #define RELAYON 0 #define RELAYOFF 1 #define LEDDELAY 0.75 #define WAITDELAY 3.0 Ticker ledBlink; // timinginterrupt for RED led InterruptIn mybutton(PTC3); //push botton with internal pullup DigitalOut myled(LED_RED); // red led DigitalOut relay(LED_GREEN); // green led float delay = WAITDELAY; int relayState = RELAYOFF; int outState = false; SLCD slcd; //define LCD display char LCDMessages[2][10] = {"TRUE", "FALS"}; void LCDMess(char *lMess){ slcd.Home();// message stays till next update slcd.clear(); slcd.printf(lMess); } void LEDBlinker(){ // RED LED interrupt outState = !outState; myled.write(outState); } void pressed() // button intterupt { relayState = !relayState; relay.write(relayState); } int main() { myled.write(outState); relay.write(relayState); mybutton.fall(&pressed); ledBlink.attach(&LEDBlinker, LEDDELAY); while (true) { // other things can be put here. LCDMess(LCDMessages[relayState]); wait(delay); } }