Russell Shomberg
/
shomberg_hw_3
Sawtooth program
Fork of shomberg_hw_3 by
Diff: main.cpp
- Revision:
- 1:cbee04784c60
- Parent:
- 0:82635173a413
- Child:
- 2:312a0a9c4485
diff -r 82635173a413 -r cbee04784c60 main.cpp --- a/main.cpp Tue Sep 25 13:41:51 2018 +0000 +++ b/main.cpp Tue Sep 25 14:59:23 2018 +0000 @@ -26,22 +26,30 @@ AnalogOut Aout(p18); // VARIABLES -float ADCdata; -int frequency; -int amplitude; +float period; +float amplitude; float i; int main() { while(1) { - for (i=0;i<1;i=i+.01){ - Aout = i; - wait(0.001); + + // Check any settings which are changed with + if (switchPosition==1) {amplitude = 1;} + else {amplitude = 0.5;} + + period = Ain; + + //printf("Amplitude = %1.2f Volts\n\r", amplitude * 3.3f); + //printf("Period = %1.2f seconds\n\r", period); + + for (i=0;i<1;i=i+.001){ + Aout = i*amplitude; + wait(0.001*period); } -/* - for (i=1;i>0;i=i-.01) { - Aout = i; - wait(0.001) + + for (i=1;i>0;i=i-.001){ + Aout = i*amplitude; + wait(0.001*period); } -*/ } }