by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

Committer:
robt
Date:
Fri Aug 31 15:26:06 2012 +0000
Revision:
0:89ccf29e350d
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robt 0:89ccf29e350d 1 /*Program Example 4.3: Sine wave on DAC output. View on oscilloscope
robt 0:89ccf29e350d 2 */
robt 0:89ccf29e350d 3 #include "mbed.h"
robt 0:89ccf29e350d 4 AnalogOut Aout(p18);
robt 0:89ccf29e350d 5 float i;
robt 0:89ccf29e350d 6 int main()
robt 0:89ccf29e350d 7 {
robt 0:89ccf29e350d 8 while(1) {
robt 0:89ccf29e350d 9 for (i=0; i<2; i=i+0.05) {
robt 0:89ccf29e350d 10 Aout=0.5+0.5*sin(i*3.14159); // Compute the sine value, + half the range
robt 0:89ccf29e350d 11 wait(.001); // Controls the sine wave period
robt 0:89ccf29e350d 12 }
robt 0:89ccf29e350d 13 }
robt 0:89ccf29e350d 14 }
robt 0:89ccf29e350d 15