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.
Fork of HelloWorld by
main.cpp
00001 #include "mbed.h" 00002 #include "PinDetect.h" 00003 00004 PwmOut myled(p26); 00005 PinDetect pb1(p16); 00006 PinDetect pb2(p17); 00007 00008 00009 float illuminate = 0.1f; 00010 00011 void pb1_dim_callback (void) { 00012 if(illuminate > 0.0f){ 00013 illuminate -= 0.1f; 00014 } 00015 } 00016 void pb2_bright_callback (void) { 00017 if(illuminate < 1.0f){ 00018 illuminate += 0.1f; 00019 } 00020 } 00021 int main() { 00022 pb1.mode(PullUp); 00023 pb2.mode(PullUp); 00024 wait(.01); 00025 00026 pb1.attach_deasserted(&pb1_dim_callback); 00027 pb2.attach_deasserted(&pb2_bright_callback); 00028 00029 pb1.setSampleFrequency(); 00030 pb2.setSampleFrequency(); 00031 00032 while(1) { 00033 myled= illuminate; 00034 wait(.1); 00035 } 00036 }
Generated on Tue Aug 9 2022 03:25:11 by
1.7.2
