Robert Abad / Mbed 2 deprecated Lab4_3

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #define INPUT_SCALAR        (0.01f)
00004 
00005 AnalogIn Ain(p19);
00006 AnalogOut Aout(p18);
00007 float i;
00008 
00009 int main()
00010 {
00011     while(1)  {
00012         for (i=0; i<2; i=i+0.05) {
00013             Aout=0.5+0.5*sin(i*3.14159);  // Compute the sine value, + half the range
00014          
00015             // Controls the sine wave period
00016             // NOTE to my fellow students:
00017             // in order to get to pot to work as an input to control the frequency,
00018             // I've had to scale the setting of the pot.  However, I have not had
00019             // enough scope time to play with the scalar value to fully understand
00020             // the how the pot affects the frequency.  So I encourage you to play
00021             // the scalar value to get it to work within the desired frequency range
00022             wait(Ain*INPUT_SCALAR);
00023         }
00024     }
00025 }
00026