TINF_TwoLEDsX

Dependencies:   mbed 2Leds

Files at this revision

API Documentation at this revision

Comitter:
martwerl
Date:
Thu Nov 15 18:18:18 2018 +0000
Parent:
0:6222193a31e0
Commit message:
TINF_mbedSimulator_2Leds

Changed in this revision

2Leds.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 6222193a31e0 -r cc9fba0cbda0 2Leds.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/2Leds.lib	Thu Nov 15 18:18:18 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/martwerl/code/2Leds/#980633ae6573
diff -r 6222193a31e0 -r cc9fba0cbda0 main.cpp
--- a/main.cpp	Mon Jun 18 14:10:34 2018 +0000
+++ b/main.cpp	Thu Nov 15 18:18:18 2018 +0000
@@ -1,58 +1,6 @@
 #include "mbed.h"
- 
- 
-class TwoLeds {
-public:
-    TwoLeds(PinName pin1, PinName pin2) : _pin1(pin1), _pin2(pin2) // Initialisierungsliste
-{     
-    _pin1 = 0; // Initialisierung mit 0
-    _pin2 = 0;
-}
- 
-void ledOn(void) 
-{
-    _pin1 = 1;
-    _pin2 = 1;
-}
- 
-void ledOff(void) 
-{
-    _pin1 = 0;
-    _pin2 = 0;
-}
- 
-void ledX() //LEDs blinken alternierend
-{
-    if( _pin1 == 0 && _pin2 == 0)
-    {
-        _pin1 = 1;
-        _pin2 = 0;
-    }
-    else if(_pin1 == 1 && _pin2 == 0)
-    {
-        _pin1 = 0;
-        _pin2 = 1;
-    }
-    else if(_pin1 == 0 && _pin2 == 1)
-    {
-        _pin1 = 1;
-        _pin2 = 0;
-    }
- 
-}
- 
-void printStatus(void) 
-{
-    printf("LED1 is now: %d\n", _pin1.read());
-    printf("LED2 is now: %d\n", _pin2.read());
-}
-    
-private:
-    DigitalOut _pin1;
-    DigitalOut _pin2;
-    
-};
- 
+#include "2Leds.h"
+
  
 DigitalOut led(LED1);
  
@@ -62,14 +10,18 @@
 {
     while (1) 
     {
-        /*twoleds.ledOn();             
+        twoleds.ledOn();             //LEDs ein/aus
         twoleds.printStatus();
         wait_ms(500);
         twoleds.ledOff();            
         twoleds.printStatus();
-        wait_ms(500); */
-        twoleds.ledX();
-        twoleds.printStatus();
-        wait_ms(500);
+        wait_ms(500); 
+
+        for(int i = 0; i <= 3; i++)
+        {
+                twoleds.ledX();
+                twoleds.printStatus();
+                wait_ms(500);
+        }
     }
 }
\ No newline at end of file