Alle LED's leuchten bei verschiedenen Lichtstärkern SW1 Sw2 Sw3 Sw4 Taster test

Dependencies:   mbed

Revision:
1:f619bd48aa06
Parent:
0:30bb00ce736e
Child:
2:429135263e22
--- a/main.cpp	Thu Apr 30 10:50:10 2015 +0000
+++ b/main.cpp	Thu Jun 18 09:19:36 2015 +0000
@@ -1,39 +1,103 @@
-/*  M0-BOARD LPC11U24 VERSION 1.0
-    BULME Graz | Elektronik FSST
-    Thomas Hauser | 3 AHELI
-    KITTV3  */
 
 #include "mbed.h"
+// ********   Definitionen  **********
+Serial pc(USBTX, USBRX);
 
-BusOut myled(P1_13,P1_12,P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1);
-int i;
-float t = 0.02;
+// Definition der Taster (Switches)
+DigitalIn  sw1(P0_10); //SW1
+DigitalIn  sw2(P0_15); //SW2 -> sein IO Pin ist laut Schaltplan der P0_15
+DigitalIn  sw3(P0_23); //SW3
+DigitalIn  sw4(P1_16); //SW4 
+
+// Definition der 12 LED's
+DigitalOut ledD1(P1_8);
+DigitalOut ledD2(P1_9);
+DigitalOut ledD3(P1_10);
+DigitalOut ledD4(P1_11);
+DigitalOut ledD13(P1_0);
+DigitalOut ledD14(P1_1);
+DigitalOut ledD15(P1_3);
+DigitalOut ledD16(P1_4);
+DigitalOut ledD17(P1_6);
+DigitalOut ledD18(P1_7);
+DigitalOut ledD19(P1_12);
+DigitalOut ledD20(P1_13);
+
+// RGB LED
 
-int main() {
-    while(1) {       
-        myled = 0x001; 
-        wait(t);
-        myled = 0x003;
-        wait(t);
-        myled = 0x007;
-        wait(t);
-        myled = 0x00F;
-        wait(t);
-        for (i = 1; i < 12; i++)
-        {
-            myled = myled << 1;
-            wait(t);             
-        }
-        myled = 0xC00;
-        wait(t);
-        myled = 0xE00;
-        wait(t);
-        myled = 0xF00;
-        wait(t);
-        for (i = 1; i < 11; i++)
-        {
-            myled = myled >> 1;
-            wait(t);
-        }
-    }
-}
\ No newline at end of file
+// LDR Input
+AnalogIn LDR(P0_12);      // Analoges einlesen des LDR 
+int a;
+// Hauptprogramm 
+int main()
+{
+    char readChar = 0;
+    pc.printf("Welcome to BERTL14\n\r");
+       
+// ****************   TASTER TEST   ********************
+     pc.printf("TASTER und LDR TEST\n\r");
+     while(1) {
+        if (sw4==1)                                       
+          ledD1=1;    
+        else {   
+          ledD1=0;         
+           }          
+        wait (0.001);    
+                                            
+        if (sw3==1)    
+          ledD2=1;    
+          ledD2=0; 
+          }  
+           wait (0.001);  
+        if (sw2==1) 
+          ledD4=1;  
+        else {         
+          ledD4=0; }
+          wait (0.001);   
+          
+        if (sw1==1)   
+            ledD3=1;      
+        else {          
+          ledD3=0;  
+          }  
+        wait (0.001);        
+
+/*************** LDR TEST *******************************/        
+        if(LDR <= 0.2)
+           ledD1=1;
+           else
+           ledD1=0;
+        
+        if(LDR <= 0.07)      
+           ledD4 = 1;       
+           else
+           ledD4 = 0;
+        
+        if (LDR <= 0.10)
+           ledD3=1;
+           else
+           ledD3=0;
+        
+        if (LDR <= 0.12)
+           ledD2=1;
+           else
+           ledD2=0;
+           
+        if (LDR <= 0.13)
+           ledD13=1;
+           else
+           ledD13=0;
+           
+      if (LDR <= 0.15)
+           ledD15=1;
+           else
+           ledD15=0;
+           
+              if (LDR <= 0.17)
+           ledD14=1;
+           else
+           ledD14=0;
+           
+         wait (0.01);                         
+}
+}