Sakis Kasampalis
/
infrared
LPC1768 IR breakbeam sensor
Diff: infrared.cpp
- Revision:
- 1:88b1d9bcf3a3
- Parent:
- 0:ca4cef100279
--- a/infrared.cpp Sat Oct 29 19:41:40 2016 +0000 +++ b/infrared.cpp Sun Nov 13 11:33:08 2016 +0000 @@ -11,13 +11,16 @@ pc.printf(home); pc.printf(cls); - while (true) { - if (!infrared) { + while (true) + { + if (!infrared) + { set_led(my_led, ON, DEBOUNCING_DELAY); std::string alert("Intrusion dectected: " + current_date_time()); show_alert(alert, TEXT_DELAY); } - else { + else + { set_led(my_led, OFF, DEBOUNCING_DELAY); } } @@ -29,13 +32,15 @@ wait(delay); } -const std::string current_date_time() { +const std::string current_date_time() +{ time_t rawtime; time(&rawtime); return ctime(&rawtime); } -void show_alert(const std::string& alert, const float delay) { +void show_alert(const std::string& alert, const float delay) +{ pc.printf(home); pc.printf(alert.c_str()); pc.printf("\r");