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.
Revision 0:9cb5dc6b57ce, committed 2016-02-02
- Comitter:
- chadlewellyn
- Date:
- Tue Feb 02 05:55:31 2016 +0000
- Commit message:
- lab 2 part 4
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 9cb5dc6b57ce main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Feb 02 05:55:31 2016 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); //tx, tr + +int main() +{ + + PwmOut led1(LED1); //establish Pwmouts for LEDs + PwmOut led2(LED2); + PwmOut led3(LED3); + + int go, count =0; // initialize variables + float pwnfinal1, pwnfinal2, pwnfinal3; + + + pc.scanf("%d,%f,%f,%f",&go, &pwnfinal1, &pwnfinal2, &pwnfinal3); // get four inputs from the user + + while(go) { + if(led1 < pwnfinal1) { // if the LED1 brightness is not higher than inputted value, keep increasing + led1 = led1 + .01; + } + if(led2 < pwnfinal2) { // if the LED2 brightness is not higher than inputted value, keep increasing + led2 = led2 + .01; + } + if(led3 < pwnfinal3) { // if the LED3 brightness is not higher than inputted value, keep increasing + led3 = led3 + .01; + } + + count = count++; // counts how many increments it takes + pc.printf("Count is %d,Led1 is %f, Led2 is %f, Led3 is %f\n",count,pwnfinal1,pwnfinal2,pwnfinal3); // prints the count and the LED values + wait(.1); // wait .1 seconds + if((led1 >= pwnfinal3) && (led2 >= pwnfinal2) && (led3 >= pwnfinal3)) { // stop if LED values anre equal to the inputted values + go = 0; + } + } +} \ No newline at end of file
diff -r 000000000000 -r 9cb5dc6b57ce mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Feb 02 05:55:31 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96 \ No newline at end of file