Examen pratique info S5

Dependencies:   mbed

Revision:
0:23d910ab014b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 18 19:31:27 2013 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+
+AnalogOut an_Out(p18);
+Ticker timer;
+
+void Sinus(void);
+void calculateSinus();
+
+int temp = 2500;
+float sins[5000];
+
+int main()
+{
+    calculateSinus();
+
+    timer.attach(&Sinus, 0.000002);
+
+    while(1) {
+        wait(1);
+    }
+
+}
+
+void calculateSinus()
+{
+    int a;
+    for(a = 0;a<5000;a++)
+    {
+        sins[a] = cos(a/5000.0*2.0*3.1416)/2+.5;
+    }
+}
+
+
+void Sinus (void)
+{
+    an_Out.write(sins[temp++]);
+    
+    if(temp == 5000)
+        temp =0;
+}