Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:cc9fba0cbda0, committed 2018-11-15
- 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 |
--- /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
--- 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