Phi Nguyen
/
app-board-Speaker
My change.
Fork of app-board-Speaker by
main.cpp@3:00613a6b0e8b, 2014-03-05 (annotated)
- Committer:
- 209108
- Date:
- Wed Mar 05 03:49:12 2014 +0000
- Revision:
- 3:00613a6b0e8b
- Parent:
- 2:cfd337edff08
Plays sound in a sine wave pitch pattern.
;
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 | 1:0a08d26b011a | 3 | DigitalIn fire(p14); |
chris | 1:0a08d26b011a | 4 | PwmOut spkr(p26); |
209108 | 3:00613a6b0e8b | 5 | float theta = 0; |
chris | 0:f86c572491c3 | 6 | |
chris | 0:f86c572491c3 | 7 | int main() |
chris | 0:f86c572491c3 | 8 | { |
chris | 2:cfd337edff08 | 9 | while (1) { |
209108 | 3:00613a6b0e8b | 10 | for (float i=2000.0; i>0.0; i+=100) { |
209108 | 3:00613a6b0e8b | 11 | theta += .2; |
209108 | 3:00613a6b0e8b | 12 | spkr.period(sin(theta)/1000); |
chris | 2:cfd337edff08 | 13 | spkr=0.5; |
chris | 2:cfd337edff08 | 14 | wait(0.1); |
chris | 2:cfd337edff08 | 15 | } |
chris | 2:cfd337edff08 | 16 | spkr=0.0; |
chris | 2:cfd337edff08 | 17 | while(!fire) {} |
chris | 0:f86c572491c3 | 18 | } |
chris | 0:f86c572491c3 | 19 | } |