Christina Lanier
/
MBED_lab1_Step4
step 4
Revision 0:7120409e3f94, committed 2014-09-04
- Comitter:
- LanierUSNA16
- Date:
- Thu Sep 04 03:06:02 2014 +0000
- Commit message:
- step 4
Changed in this revision
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
step4.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Sep 04 03:06:02 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/step4.cpp Thu Sep 04 03:06:02 2014 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" +//Lab 2, step 4 + +//code given by professor +Serial pc(USBTX, USBRX); + +//establish pwmout on LED1 +PwmOut pwmled(LED1); + +int main() + {//begin main + //create dutycycle variable + float dutycycle=0.0; + + while (1) + { + //computer sampling rate + pc.baud(921600); + + //prompt the user to enter the desired duty cycle, i.e. brightness of light + printf("Enter \n "); + //assign user input to variable 'dutycycle' + scanf("%f", &dutycycle); + + //set the dutycle, i.e. brightness, to the user input + pwmled.write(dutycycle); + + //wait 1 second before reiterating + wait(1); + + }//end while + + + }//end main \ No newline at end of file