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:ce916b042621, committed 2018-09-27
- Comitter:
- ccschneider
- Date:
- Thu Sep 27 14:24:55 2018 +0000
- Commit message:
- Sawtooth waveform on oscilloscope with variable amplitude and frequency
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 27 14:24:55 2018 +0000 @@ -0,0 +1,31 @@ +// Cecilia Schneider, OCE 360, September 24,2018 +// HW #3, exercise 4, Analog I/O +// Sawtooth waveform on DAC output to view on oscilloscope +#include "mbed.h" +AnalogOut Aout(p18); //oscilliscope on pin 18 +AnalogIn Ain(p20); //potentiometer on pin 20 +DigitalIn Sin(p7); //switch on pin 7 +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; + wait(0.001*ADCin); //allows user to control frequency with potentiometer + } + for (j=Switchin;j>0;j=j-0.001) { + Aout=j; + wait(0.001*ADCin); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Sep 27 14:24:55 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file