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
- Committer:
- kstokely
- Date:
- 2018-12-12
- Revision:
- 0:c57b9d018b9f
- Child:
- 1:5c0202cb8e6d
File content as of revision 0:c57b9d018b9f:
#include "mbed.h"
Serial pc(USBTX, USBRX); // tx, rx
PwmOut led1(p23);
PwmOut led2(p24);
PwmOut led3(p25);
float brightness = 1.0;
int main() {
pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n");
while(1) {
char c = pc.getc();
if((c == 'u') && (brightness < 1.0)) {
brightness += 0.01;
led1 = brightness;
led2 = brightness;
led3 = brightness;
}
if((c == 'd') && (brightness > 0.0)) {
brightness -= 0.01;
led1 = brightness;
led2 = brightness;
led3 = brightness;
}
}
}