A sawtooth waveform generator using analog output, with smoothness setting over potentiometer.
Dependencies: mbed
main.cpp@0:0713d899de2b, 2014-12-17 (annotated)
- Committer:
- tbjazic
- Date:
- Wed Dec 17 16:35:37 2014 +0000
- Revision:
- 0:0713d899de2b
- Child:
- 1:91e1f50eac98
Initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tbjazic | 0:0713d899de2b | 1 | #include "mbed.h" |
tbjazic | 0:0713d899de2b | 2 | |
tbjazic | 0:0713d899de2b | 3 | AnalogOut out(p18); |
tbjazic | 0:0713d899de2b | 4 | AnalogIn pot1(p19); |
tbjazic | 0:0713d899de2b | 5 | |
tbjazic | 0:0713d899de2b | 6 | int main() { |
tbjazic | 0:0713d899de2b | 7 | int numberOfPoints; |
tbjazic | 0:0713d899de2b | 8 | while(1) { |
tbjazic | 0:0713d899de2b | 9 | numberOfPoints = 10 + pot1 * 90; // 10 to 100 points |
tbjazic | 0:0713d899de2b | 10 | for (int i = 0; i < numberOfPoints; i++) { |
tbjazic | 0:0713d899de2b | 11 | out = i / numberOfPoints; |
tbjazic | 0:0713d899de2b | 12 | wait_us(10000/numberOfPoints); |
tbjazic | 0:0713d899de2b | 13 | } |
tbjazic | 0:0713d899de2b | 14 | } |
tbjazic | 0:0713d899de2b | 15 | } |