by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
main.cpp
00001 /*Program Example 4.3: Sine wave on DAC output. View on oscilloscope 00002 */ 00003 #include "mbed.h" 00004 AnalogOut Aout(p18); 00005 float i; 00006 int main() 00007 { 00008 while(1) { 00009 for (i=0; i<2; i=i+0.05) { 00010 Aout=0.5+0.5*sin(i*3.14159); // Compute the sine value, + half the range 00011 wait(.001); // Controls the sine wave period 00012 } 00013 } 00014 } 00015
Generated on Sun Aug 21 2022 10:44:49 by 1.7.2