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 #include "mbed.h" 00002 #include "PinDetect.h" 00003 00004 PwmOut led(LED1); 00005 PinDetect pbdim(p7); 00006 PinDetect pbbright(p6); 00007 float volatile brightness = 0.5f; 00008 void pbdim_hit_callback (void) { 00009 if(1.0f > brightness || brightness >= 0.0f) { 00010 brightness+= 0.1f; 00011 } 00012 } 00013 void pbbright_hit_callback (void) { 00014 if (0.0f < brightness || brightness <= 1.0f) { 00015 brightness -= 0.1f; 00016 } 00017 } 00018 int main() { 00019 pbdim.mode(PullUp); 00020 pbbright.mode(PullUp); 00021 wait(0.001); 00022 00023 pbdim.attach_deasserted(&pbdim_hit_callback); 00024 pbdim.setSampleFrequency(); 00025 pbbright.attach_deasserted(&pbbright_hit_callback); 00026 pbbright.setSampleFrequency(); 00027 while(1) { 00028 led = brightness; 00029 wait(.2); 00030 } 00031 } 00032
Generated on Thu Sep 8 2022 07:35:57 by
1.7.2