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
Diff: main.cpp
- Revision:
- 3:798a084f105a
- Parent:
- 2:549ed5b0a8d0
- Child:
- 4:986fa54b04b5
--- a/main.cpp Thu Nov 10 17:43:03 2016 +0000
+++ b/main.cpp Thu Nov 10 17:45:08 2016 +0000
@@ -1,24 +1,9 @@
#include "mbed.h"
-Serial pc(USBTX, USBRX); // tx, rx
PwmOut PWM1(p21);
-float brightness=0.0;
+PwmOut PWM2(p22);
int main()
{
PWM1.period(0.010); // set PWM period to 10 ms
PWM1=0.8; // set duty cycle to 80%
- pc.printf("Control of LED dimmer by host terminal\n\r");
- pc.printf("Press 'u' = brighter, 'd' = dimmer\n\r");
- while(1) {
- char c = pc.getc();
- wait(0.001);
- if((c == 'u') && (brightness < 1.0)) {
- brightness += 0.1;
- PWM1= brightness;
- }
- if((c == 'd') && (brightness > 0.0)) {
- brightness -= 0.1;
- PWM1= brightness;
- }
- pc.printf("%c %1.3f \n \r",c,brightness);
- }
+ PWM2=0.2; // set duty cycle to 20%
}
\ No newline at end of file