Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- 302Instructor
- Date:
- 2015-01-22
- Revision:
- 0:40edabd603cf
File content as of revision 0:40edabd603cf:
#include "mbed.h"
#include <iostream>
Serial pc(USBTX, USBRX);
AnalogOut Aout(PTE30);
float i,delay,f;
bool flag = 0;
float brightness = 0.0;
void delay_change()
{
Aout = 0;
printf("\n\rPlease enter new frequency: ");
std::cin >> f;
delay = 1/(f*200);
float freq = 1/(delay*200);
printf("\n\rFrequency: %f",freq);
flag = 0;
}
int main()
{
printf("\n\rWelcome, please enter a frequency: \n");
std::cin >> f;
pc.attach(*delay_change);
delay = 1/(f*200);
float freq = 1/(delay*200);
printf("\n\rFrequency: %f",freq);
while(1) {
for (i=0.01; i<=2; i=i+0.01) {
if (flag == 0) {
printf("\n\rPress ENTER on the keyboard to input a new frequency. \n");
flag = 1;
}
Aout=0.5+0.5*sin(i*3.14159);
wait(delay);
}
}
}