sinusoid wave generator with pot input
main.cpp
- Committer:
- rabad1
- Date:
- 2013-10-25
- Revision:
- 0:51c3fa0f0a03
File content as of revision 0:51c3fa0f0a03:
#include "mbed.h"
#define INPUT_SCALAR (0.01f)
AnalogIn Ain(p19);
AnalogOut Aout(p18);
float i;
int main()
{
while(1) {
for (i=0; i<2; i=i+0.05) {
Aout=0.5+0.5*sin(i*3.14159); // Compute the sine value, + half the range
// Controls the sine wave period
// NOTE to my fellow students:
// in order to get to pot to work as an input to control the frequency,
// I've had to scale the setting of the pot. However, I have not had
// enough scope time to play with the scalar value to fully understand
// the how the pot affects the frequency. So I encourage you to play
// the scalar value to get it to work within the desired frequency range
wait(Ain*INPUT_SCALAR);
}
}
}