A sawtooth waveform generator using analog output, with smoothness setting over potentiometer.
Dependencies: mbed
Revision 1:91e1f50eac98, committed 2014-12-18
- Comitter:
- tbjazic
- Date:
- Thu Dec 18 07:37:45 2014 +0000
- Parent:
- 0:0713d899de2b
- Commit message:
- Cast operator (float) added for accurate division, and maximum number of points reduced to 50.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 0713d899de2b -r 91e1f50eac98 main.cpp --- a/main.cpp Wed Dec 17 16:35:37 2014 +0000 +++ b/main.cpp Thu Dec 18 07:37:45 2014 +0000 @@ -6,9 +6,9 @@ int main() { int numberOfPoints; while(1) { - numberOfPoints = 10 + pot1 * 90; // 10 to 100 points + numberOfPoints = 10 + pot1 * 40; // 10 to 50 points for (int i = 0; i < numberOfPoints; i++) { - out = i / numberOfPoints; + out = (float) i / numberOfPoints; wait_us(10000/numberOfPoints); } }