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.
Revision 0:40edabd603cf, committed 2015-01-22
- Comitter:
- 302Instructor
- Date:
- Thu Jan 22 19:56:31 2015 +0000
- Commit message:
- 1/22/15
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Jan 22 19:56:31 2015 +0000
@@ -0,0 +1,41 @@
+#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);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jan 22 19:56:31 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file