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.
Dependencies: mbed MCP23S17 PinDetect USBDevice
main.cpp
00001 #include "mbed.h" 00002 #include "RGBLed.h" 00003 #include "PinDetect.h" 00004 //#include "part4.h" 00005 //#include "part6.h" 00006 //#include "part7.h" 00007 //#include "part8.h" 00008 //#include "part9.h" 00009 //#include "watchdog_ec.h" 00010 //#include "powermanagement_ec.h" 00011 #include "mouse_ec.h" 00012 00013 //DigitalOut myled(p26); 00014 //PwmOut builtinLED(LED1); 00015 //DigitalIn pb(p22); 00016 //DigitalIn pb2(p21); 00017 00018 // p20 is most significant bit 00019 //PinDetect redSelect(p18); 00020 //PinDetect blueSelect(p19); 00021 //PinDetect greenSelect(p20); 00022 // 00023 //PinName redPin = p24; 00024 //PinName greenPin = p25; 00025 //PinName bluePin = p23; 00026 // 00027 //PinDetect pb1(p21); 00028 //PinDetect pb2(p22); 00029 00030 float volatile p = 1.0f; 00031 00032 void pb1_hit_callback() { 00033 if (p > 0) { 00034 p -= 0.1f; 00035 } 00036 } 00037 00038 void pb2_hit_callback() { 00039 if (p < 1) { 00040 p += 0.1f; 00041 } 00042 } 00043 00044 //RGBLed myRGBLed = RGBLed(redPin, greenPin, bluePin); 00045 00046 int main() { 00047 00048 // pb1.mode(PullUp); 00049 // pb2.mode(PullUp); 00050 // redSelect.mode(PullUp); 00051 // greenSelect.mode(PullUp); 00052 // blueSelect.mode(PullUp); 00053 // wait(0.1); 00054 // 00055 // pb1.attach_asserted(&pb1_hit_callback); 00056 // pb2.attach_asserted(&pb2_hit_callback); 00057 // pb1.setSampleFrequency(); 00058 // pb2.setSampleFrequency(); 00059 // 00060 // float redVal = 0.0f; 00061 // float greenVal = 0.0f; 00062 // float blueVal = 0.0f; 00063 00064 while(1) { 00065 // Part 1 00066 // myled = !pb; 00067 00068 // Part 2 00069 // builtinLED = p; 00070 // wait(0.5); 00071 00072 // Part 3 00073 // if (!redSelect) { 00074 // redVal = 1.0f * p; 00075 // } else { 00076 // redVal = 0.0f; 00077 // } 00078 // if (!greenSelect) { 00079 // greenVal = 1.0f * p; 00080 // } else { 00081 // greenVal = 0.0f; 00082 // } 00083 // if (!blueSelect) { 00084 // blueVal = 1.0f * p; 00085 // } else { 00086 // blueVal = 0.0f; 00087 // } 00088 // myRGBLed.write(redVal, greenVal, blueVal); 00089 // wait(0.5); 00090 00091 // Part 4 00092 // run_part4(); 00093 00094 // Part 5 in separate project 00095 00096 // Part 6 in separate project 00097 00098 // Part 7 00099 // run_part7(); 00100 00101 // Part 8 00102 // run_part8(); 00103 00104 // Part 9 00105 // run_part9(); 00106 00107 // Part 10 in separate project 00108 00109 // Watchdog Extra Credit 00110 // run_watchdogEC(); 00111 00112 // Power Management Extra Credit 00113 // run_powermanagementEC(); 00114 00115 // USB Mouse Extra Credit 00116 run_mouseEC(); 00117 00118 } 00119 }
Generated on Sun Jul 17 2022 17:11:11 by
1.7.2