Christina Lanier
/
MBED_lab1_Step4
step 4
Diff: step4.cpp
- Revision:
- 0:7120409e3f94
--- /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