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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:1dbc25c03bad
- Child:
- 1:506c8ffad3d8
diff -r 000000000000 -r 1dbc25c03bad main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Sep 04 19:07:09 2015 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+
+// The sinewave is created on this pin
+AnalogOut aout(p18);
+
+int main()
+{
+ const double pi = 3.141592653589793238462;
+ const double amplitude = 0.5f;
+ const double offset = 65535/2;
+ double rads = 0.0;
+ uint16_t sample = 0;
+
+ while(1) {
+ // sinewave output
+ for (int i = 0; i < 360; i++) {
+ rads = (pi * i) / 180.0f;
+ sample = (uint16_t)(amplitude * (offset * (cos(rads + pi))) + offset);
+ aout.write_u16(sample);
+ }
+ }
+}