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 /* lighting-system-firmware/source/main.cpp */ 00002 00003 #include "mbed.h" 00004 #include "led.h" // Abstracts away the differens between the LED types 00005 00006 // PIR sensor acts as an interrupt - signals us whenever it goes high (or low) 00007 InterruptIn pir(PIR_PIN); // This pin value comes out mbed_app.json 00008 00009 // Whenever movement is not detected 00010 void pir_fall() { 00011 setRgbColor(0.0f, 0.0f, 0.0f); 00012 } 00013 00014 // Whenever movement is detected 00015 void pir_rise() { 00016 // set the color to red 00017 setRgbColor(1.0f, 0.0f, 0.0f); 00018 } 00019 00020 int main(int, char**) { 00021 // Blink the LED when the application starts 00022 setRgbColor(0.0f, 1.0f, 0.0f); 00023 Thread::wait(500); 00024 setRgbColor(0.0f, 0.0f, 0.0f); 00025 00026 // The PIR sensor uses interrupts, no need to poll 00027 pir.fall(&pir_fall); 00028 pir.rise(&pir_rise); 00029 }
Generated on Mon Jul 18 2022 13:21:17 by
1.7.2