Example program to do a frequency sweep on the speaker
Fork of app-shield-speaker by
main.cpp@5:aba9347842e0, 2017-09-19 (annotated)
- Committer:
- sarahmarshy
- Date:
- Tue Sep 19 19:29:12 2017 +0000
- Revision:
- 5:aba9347842e0
- Parent:
- 3:3bb3e6051175
Update to mbed OS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris | 0:f86c572491c3 | 1 | #include "mbed.h" |
chris | 0:f86c572491c3 | 2 | |
chris | 3:3bb3e6051175 | 3 | DigitalIn fire(D4); |
chris | 3:3bb3e6051175 | 4 | PwmOut spkr(D6); |
chris | 0:f86c572491c3 | 5 | |
chris | 0:f86c572491c3 | 6 | int main() |
chris | 0:f86c572491c3 | 7 | { |
chris | 2:cfd337edff08 | 8 | while (1) { |
chris | 2:cfd337edff08 | 9 | for (float i=2000.0; i<10000.0; i+=100) { |
chris | 2:cfd337edff08 | 10 | spkr.period(1.0/i); |
chris | 2:cfd337edff08 | 11 | spkr=0.5; |
chris | 3:3bb3e6051175 | 12 | wait(0.02); |
chris | 2:cfd337edff08 | 13 | } |
chris | 2:cfd337edff08 | 14 | spkr=0.0; |
chris | 2:cfd337edff08 | 15 | while(!fire) {} |
chris | 0:f86c572491c3 | 16 | } |
chris | 0:f86c572491c3 | 17 | } |