Generate a 5kHz Saw Tooth wave, with 10 steps per cycle

Dependencies:   mbed

Dependents:   CPP

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 AnalogOut speaker(p18);
00004 
00005 int main() {
00006     while (1) {
00007         for (float i = 0.0 ; i <= 1.0 ; i += 0.1 ) {
00008             speaker = i;
00009             wait (0.00001); // 5kHz, with 10 steps
00010         }
00011     }
00012 }