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 #include "RGB_LED.h" 00004 00005 RGBLed myRGBled(p22,p23,p24); 00006 PinDetect pb1(p16); 00007 PinDetect pb2(p17); 00008 DigitalIn switchInputRed(p13); 00009 DigitalIn switchInputBlue(p14); 00010 DigitalIn switchInputGreen(p15); 00011 00012 00013 float illuminateRed = 0.0f; 00014 float illuminateBlue = 0.0f; 00015 float illuminateGreen = 0.0f; 00016 bool greenOn =false; 00017 bool blueOn = false; 00018 bool redOn = false; 00019 00020 00021 void pb1_dim_callback (void) { 00022 if(redOn && illuminateRed > 0.0f){ 00023 illuminateRed -= 0.1f; 00024 } 00025 if(greenOn && illuminateGreen > 0.0f){ 00026 illuminateGreen -= 0.1f; 00027 } 00028 if(blueOn && illuminateBlue > 0.0f) { 00029 illuminateBlue -= 0.1f; 00030 } 00031 } 00032 void pb2_bright_callback (void) { 00033 if(redOn && illuminateRed <= 1.0f){ 00034 illuminateRed += 0.1f; 00035 } 00036 if(greenOn && illuminateGreen <= 1.0f){ 00037 illuminateGreen += 0.1f; 00038 } 00039 if(blueOn && illuminateBlue <= 1.0f) { 00040 illuminateBlue += 0.1f; 00041 } 00042 } 00043 int main() { 00044 switchInputRed.mode(PullUp); 00045 switchInputGreen.mode(PullUp); 00046 switchInputBlue.mode(PullUp); 00047 pb1.mode(PullUp); 00048 pb2.mode(PullUp); 00049 wait(.01); 00050 00051 pb1.attach_deasserted(&pb1_dim_callback); 00052 pb2.attach_deasserted(&pb2_bright_callback); 00053 00054 pb1.setSampleFrequency(); 00055 pb2.setSampleFrequency(); 00056 00057 while(1) { 00058 redOn = !switchInputRed; 00059 blueOn = !switchInputBlue; 00060 greenOn = !switchInputGreen; 00061 myRGBled.write(illuminateRed,illuminateGreen,illuminateBlue); 00062 wait(.1); 00063 } 00064 }
Generated on Thu Jul 28 2022 00:26:51 by
1.7.2