M0_Übung_5

Dependencies:   mbed

Fork of M0_Lektion05 by Gottfried Enenkel

Revision:
1:d62ca09b4171
Parent:
0:56dbb8ec442b
--- a/main.cpp	Mon Mar 09 12:13:38 2015 +0000
+++ b/main.cpp	Thu Apr 21 07:56:15 2016 +0000
@@ -1,29 +1,66 @@
-//  HIMBED _lektion05   int   double 
-//  HTL BULME Graz       by Enenkel      26.2.2014
-//  Da findet ihr mehr Info über C++    http://www.cplusplus.com/doc/tutorial/program_structure/
-//  Aufgabe:
-//  Erstelle ev. mit Hilfe von Bitschieben (Lektion 2) einen Punkt,
-//  der über die 12 LED huscht, und dabei immer schneller wird.
-//  Der Punkt soll 5 x über die LED huschen.
-//  Erst nach drücken der Reset Taste soll das Programm erneut starten.
-#include "mbed.h"
+#include "mbed.h" 
+
+// **** DEFINITIONEN ****
+
+BusOut led(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1);
 
-DigitalOut led(LED1);
-int i;     
-double x;  
+int I;
+double X;
+
+ // **** HAUPTPROGRAMM ****
+ 
+int main()
+{
+I=1;
+X=2;
 
-int main() {
-i=1;
-x=0.1;
-    while(i<=25) {
-        led = 1;
-        wait(x);
-        led = 0;
-        wait(x);
-        i++;       // i=i+1
-        x=x*1.1;   // Zeit x verlängern
-    }
+    while(I<=5) 
+        {
+            led=0x000;        //LED **** **** **** 0000 0000 0000
+            wait(X);
+            X=X*0.999;
+            led=0x001;        //LED **** **** ***X 0000 0000 0001     
+            wait (X);
+            X=X*0.999;
+            led=0x002;        //LED **** **** **X* 0000 0000 0010
+            wait (X);
+            X=X*0.999;
+            led=0x004;        //LED **** **** *X** 0000 0000 0100
+            wait (X);
+            X=X*0.999;
+            led=0x008;        //LED **** **** X*** 0000 0000 1000
+            wait (X);
+            X=X*0.999;
+            led=0x010;        //LED **** ***X **** 0000 0001 0000
+            wait (X);
+            X=X*0.999;
+            led=0x020;        //LED **** **X* **** 0000 0010 0000
+            wait (X);
+            X=X*0.999;
+            led=0x040;        //LED **** *X** **** 0000 0100 0000
+            wait (X);
+            X=X*0.999;
+            led=0x080;        //LED **** X*** **** 0000 1000 0000
+            wait (X);
+            X=X*0.999;
+            led=0x100;        //LED ***X **** **** 0001 0000 0000 
+            wait (X);
+            X=X*0.999;
+            led=0x200;        //LED **X* **** **** 0010 0000 0000 
+            wait (X);
+            X=X*0.999;
+            led=0x400;        //LED *X** **** **** 0100 0000 0000 
+            wait (X);
+            X=X*0.999;
+            led=0x800;        //LED X*** **** **** 1000 0000 0000 
+            wait (X);
+            X=X*0.999;
+            led=0x000;        //LED **** **** **** 0000 0000 0000 
+            wait (X);
+            X=X*0.999;
+            
+            I++;
+            
+        }
 }
-// ACHTUNG der M0 führt die Software 2x aus,
-// dies obwohl er sie nur einmal ausführen sollte!
-// liegt vermutlich am Compiler..... 
+// **** ENDE ****
\ No newline at end of file