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 Lab3_Interrupt by
Revision 1:6acc584b5a38, committed 2015-10-31
- Comitter:
- BrentLei
- Date:
- Sat Oct 31 02:43:54 2015 +0000
- Parent:
- 0:37b9817db00a
- Child:
- 2:ebbc2bafeb5f
- Commit message:
- nRF51
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu May 21 02:23:41 2015 +0000
+++ b/main.cpp Sat Oct 31 02:43:54 2015 +0000
@@ -2,9 +2,7 @@
PwmOut led(D5);
InterruptIn button_up(A2);
-InterruptIn button_center(D4);
InterruptIn button_down(A3);
-Serial pc(SERIAL_TX, SERIAL_RX);
double brightness = 1.0;
double brightness_inc = 0.1;
@@ -19,32 +17,13 @@
brightness += brightness_inc;
}
-void press_center()
-{
- brightness = (brightness>0.5)?1.0:0.0;
-}
-
-void serial_in()
-{
- char ch = getc(pc);
- if(ch < '0' || ch > '9')
- pc.printf("Please input a number between 0 to 9.\r\n");
- else
- brightness = 1 - (ch - '0') / 10.0;
-}
-
int main()
{
- pc.baud(9600);
- pc.attach(&serial_in);
- pc.printf("Hello PWM!\r\n");
- pc.printf("Please input a number between 0 to 9.\r\n");
// Set PWM
led.write(brightness);
button_up.fall(&press_up);
button_down.fall(&press_down);
- button_center.fall(&press_center);
while (1) {
brightness = (brightness>1.0)?0.0:brightness;
