M0 Board

Dependencies:   LM75B mbed

Revision:
0:6cba50f89959
diff -r 000000000000 -r 6cba50f89959 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Apr 25 07:02:35 2017 +0000
@@ -0,0 +1,381 @@
+// HIMBED _TEST1_V2 
+// Diese Software testet die verschiedenen Funktionen des M0 Boards  
+// BULME Graz,     by Enenkel   26.12.2015
+/* zuerst __ RGB TEST; dann ___ D1 bis D13 2x getestet
+          __ Taster Testen  ___ LDR Testen
+          __ FTDI TEST (mit RES) ___ POTI Test
+          __ TEMP Test  --- fehlt nur noch UHR und RAM */
+ 
+#include "mbed.h"
+#include "LM75B.h"
+// ********   Definitionen  **********
+Serial pc(USBTX, USBRX);
+
+// Definition der Taster (Switches)
+DigitalIn  Schalter3(P0_10); //SW1
+DigitalIn  Schalter4(P0_15); //SW2 -> sein IO Pin ist laut Schaltplan der P0_15
+DigitalIn  Schalter2(P0_23); //SW3
+DigitalIn  Schalter1(P1_16); //SW4 
+
+// Definition der 12 LED's
+DigitalOut Led1(P1_8);
+DigitalOut Led2(P1_9);
+DigitalOut Led3(P1_10);
+DigitalOut Led4(P1_11);
+DigitalOut Led5(P1_0);
+DigitalOut Led6(P1_1);
+DigitalOut Led7(P1_3);
+DigitalOut Led8(P1_4);
+DigitalOut Led9(P1_6);
+DigitalOut Led10(P1_7);
+DigitalOut Led11(P1_12);
+DigitalOut Led12(P1_13);
+
+// RGB LED
+DigitalOut RGBgrun(P0_9);   // grüne LED  wenn es anders ist bitte mir melden ! ! !
+DigitalOut RGBblau(P1_15);  // blaue LED
+DigitalOut RGBrot(P0_21);  // rote  LED
+// LDR Input
+AnalogIn LDR(P0_12);      // Analoges einlesen des LDR 
+AnalogIn POTI (P0_11);    // Analog in des POTI
+//Create an LM75B object at the default address (ADDRESS_0)
+LM75B sensor(p28, p27);    //i²C Sensor Leitungen
+
+int b;                     // Wert für POTI
+int a;                    
+
+
+void Leds();
+void RGB();
+void Licht();
+void Poti();
+void Temp();
+void Aus(int i);
+
+int main()
+{
+    int i = 0;
+    RGBblau = 1;
+    RGBrot = 1;
+    RGBgrun = 1;
+
+    do {
+        if(Schalter1 == 1) {
+            i = 1;
+        }
+
+        if(Schalter2 == 1) {
+            i = 2;
+        }
+
+        if(Schalter3 == 1) {
+            i = 3;
+        }
+
+        if(Schalter4 == 1) {
+            i = 4;
+        }
+
+        if(Schalter1 == 1 && Schalter2 == 1) {
+            i = 5;
+        }
+
+        if(Schalter3 == 1 && Schalter4 == 1) {
+            i = 6;
+        }
+
+        //-------------------------------------------------
+
+        if(i == 1) {
+            Leds();
+        }
+
+        if(i == 2) {
+            RGB();
+        }
+
+        if(i == 3) {
+            Licht();
+        }
+
+        if(i == 4) {
+            Poti();
+        }
+
+        if(i == 5) {
+            Temp();
+        }
+        if(i == 6) {
+            Aus(i);
+        }
+    } while(1);
+}
+
+void Leds()
+{
+    Led1=Led2=Led3=Led4=Led5=Led6=Led7=Led8=Led9=Led10=Led11=Led12= 0;
+    Led1 = 1;
+    wait(0.5);
+    Led2 = 1;
+    wait(0.5);
+    Led3 = 1;
+    wait(0.5);
+    Led4 = 1;
+    wait(0.5);
+    Led5 = 1;
+    wait(0.5);
+    Led6 = 1;
+    wait(0.5);
+    Led7 = 1;
+    wait(0.5);
+    Led8 = 1;
+    wait(0.5);
+    Led9 = 1;
+    wait(0.5);
+    Led10 = 1;
+    wait(0.5);
+    Led11 = 1;
+    wait(0.5);
+    Led12 = 1;
+    wait(0.5);
+    Led1 = 0;
+    wait(0.5);
+    Led2 = 0;
+    wait(0.5);
+    Led3 = 0;
+    wait(0.5);
+    Led4 = 0;
+    wait(0.5);
+    Led5 = 0;
+    wait(0.5);
+    Led6 = 0;
+    wait(0.5);
+    Led7 = 0;
+    wait(0.5);
+    Led8 = 0;
+    wait(0.5);
+    Led9 = 0;
+    wait(0.5);
+    Led10 = 0;
+    wait(0.5);
+    Led11 = 0;
+    wait(0.5);
+    Led12 = 0;
+    wait(0.5);
+}
+
+void RGB()
+{
+    RGBgrun = 0;
+    RGBrot = 0;
+    wait(0.5);
+    RGBgrun = 1;
+    wait(0.5);
+    RGBblau = 0;
+    wait(0.5);
+    RGBrot = 1;
+    wait(0.5);
+    RGBgrun = 0;
+    wait(0.5);
+    RGBblau = 1;
+    wait(0.5);
+    RGBgrun = 1;
+    wait(0.5);
+}
+
+void Licht()
+{
+    if(LDR <= 0.08) {
+        Led12 = 1;
+    } else {
+        Led12 = 0;
+    }
+    if(LDR <= 0.16) {
+        Led11 = 1;
+    } else {
+        Led11 = 0;
+    }
+    if(LDR <= 0.24) {
+        Led10 = 1;
+    } else {
+        Led10 = 0;
+    }
+    if(LDR <= 0.32) {
+        Led9 = 1;
+    } else {
+        Led9 = 0;
+    }
+    if(LDR <= 0.40) {
+        Led8 = 1;
+    } else {
+        Led8 = 0;
+    }
+    if(LDR <= 0.48) {
+        Led7 = 1;
+    } else {
+        Led7 = 0;
+    }
+    if(LDR <= 0.56) {
+        Led6 = 1;
+    } else {
+        Led6 = 0;
+    }
+    if(LDR <= 0.64) {
+        Led5 = 1;
+    } else {
+        Led5 = 0;
+    }
+    if(LDR <= 0.72) {
+        Led4 = 1;
+    } else {
+        Led4 = 0;
+    }
+    if(LDR <= 0.80) {
+        Led3 = 1;
+    } else {
+        Led3 = 0;
+    }
+    if(LDR <= 0.88) {
+        Led2 = 1;
+    } else {
+        Led2 = 0;
+    }
+    if(LDR <= 1.00) {
+        Led1 = 1;
+    } else {
+        Led1 = 0;
+    }
+}
+
+void Poti()
+{
+    if(POTI <= 0.08) {
+        Led12 = 1;
+    } else {
+        Led12 = 0;
+    }
+    if(POTI <= 0.16) {
+        Led11 = 1;
+    } else {
+        Led11 = 0;
+    }
+    if(POTI <= 0.24) {
+        Led10 = 1;
+    } else {
+        Led10 = 0;
+    }
+    if(POTI <= 0.32) {
+        Led9 = 1;
+    } else {
+        Led9 = 0;
+    }
+    if(POTI <= 0.40) {
+        Led8 = 1;
+    } else {
+        Led8 = 0;
+    }
+    if(POTI <= 0.48) {
+        Led7 = 1;
+    } else {
+        Led7 = 0;
+    }
+    if(POTI <= 0.56) {
+        Led6 = 1;
+    } else {
+        Led6 = 0;
+    }
+    if(POTI <= 0.64) {
+        Led5 = 1;
+    } else {
+        Led5 = 0;
+    }
+    if(POTI <= 0.72) {
+        Led4 = 1;
+    } else {
+        Led4 = 0;
+    }
+    if(POTI <= 0.80) {
+        Led3 = 1;
+    } else {
+        Led3 = 0;
+    }
+    if(POTI <= 0.88) {
+        Led2 = 1;
+    } else {
+        Led2 = 0;
+    }
+    if(POTI <= 1.00) {
+        Led1 = 1;
+    } else {
+        Led1 = 0;
+    }
+}
+
+void Temp()
+{
+    if(sensor >= 0.00) {
+        Led1 = 1;
+    } else {
+        Led1 = 0;
+    }
+    if(sensor >= 10.00) {
+        Led2 = 1;
+    } else {
+        Led2 = 0;
+    }
+    if(sensor >= 20.00) {
+        Led3 = 1;
+    } else {
+        Led3 = 0;
+    }
+    if(sensor >= 30.00) {
+        Led4 = 1;
+    } else {
+        Led4 = 0;
+    }
+    Led5 = 0;
+    if(sensor >= 31.00) {
+        Led6 = 1;
+    } else {
+        Led6 = 0;
+    }
+    if(sensor >= 32.00) {
+        Led7 = 1;
+    } else {
+        Led7 = 0;
+    }
+    if(sensor >= 33.00) {
+        Led8 = 1;
+    } else {
+        Led8 = 0;
+    }
+    if(sensor >= 34.00) {
+        Led9 = 1;
+    } else {
+        Led9 = 0;
+    }
+    if(sensor >= 35.00) {
+        Led10 = 1;
+    } else {
+        Led10 = 0;
+    }
+    if(sensor >= 36.00) {
+        Led11 = 1;
+    } else {
+        Led11 = 0;
+    }
+    if(sensor >= 37.00) {
+        Led12 = 1;
+    } else {
+        Led12 = 0;
+    }
+}
+
+void Aus(int i)
+{
+    RGBblau = 1;
+    RGBrot = 1;
+    RGBgrun = 1;
+    Led1=Led2=Led3=Led4=Led5=Led6=Led7=Led8=Led9=Led10=Led11=Led12= 0;
+    i = 0;
+}
\ No newline at end of file