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:efa0dd52a0d8, committed 2018-10-18
- Comitter:
- ccschneider
- Date:
- Thu Oct 18 13:52:25 2018 +0000
- Commit message:
- PWM;
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 efa0dd52a0d8 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Oct 18 13:52:25 2018 +0000 @@ -0,0 +1,34 @@ +// Cecilia Schneider, OCE 360, September 9,2018 +// HW #4, PWM Output +#include "mbed.h" +AnalogOut Aout(p18); //oscilliscope on pin 18 +AnalogIn Ain(p20); //potentiometer on pin 20 +DigitalIn Sin(p7); //switch on pin 7 +PwmOut PWM1(p21); +PwmOut led(LED1); +float ADCin; +float Switchin; +float i; +float j; + +int main() { + while(1) { + ADCin = Ain; // + if (Sin == 1) { + Switchin = 1; //when the switch is on, the amplitude will be 1 + } + else if (Sin == 0) { + Switchin = 0.5; //when the switch is off, the amplitude will be 0.5 + } + for (i=0;i<Switchin;i=i+0.001) { + Aout=i; + PWM1=i; + wait(0.001*ADCin); //allows user to control frequency with potentiometer + } + for (j=Switchin;j>0;j=j-0.001) { + Aout=j; + PWM1=j; + wait(0.001*ADCin); + } + } +}
diff -r 000000000000 -r efa0dd52a0d8 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Oct 18 13:52:25 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file