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 0:e8fedaebc8e3, committed 2018-06-21
- Comitter:
- Wizo
- Date:
- Thu Jun 21 12:42:52 2018 +0000
- Commit message:
- HexLeds
Changed in this revision
diff -r 000000000000 -r e8fedaebc8e3 HexLeds.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HexLeds.cpp Thu Jun 21 12:42:52 2018 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" +#include "HexLeds.h" + + +void HexLeds::input(void) +{ + int temp = 0; + + scanf ("%d", &temp); + + if(temp < 16) + _Hexwert = temp; + else + _Hexwert = 0; +} + +void HexLeds::output(void) +{ + printf("Wert = %d\n", _Hexwert); +} + +void HexLeds::hexOut(void) +{ + _Leds = _Hexwert; +} + +void HexLeds::printStatus(void) +{ + printf("LED Status:\n LED1: %d\n LED2: %d\n LED3: %d\n LED4: %d\n", + _pin1.read(), _pin2.read(), _pin3.read(), _pin4.read()); +} \ No newline at end of file
diff -r 000000000000 -r e8fedaebc8e3 HexLeds.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HexLeds.h Thu Jun 21 12:42:52 2018 +0000 @@ -0,0 +1,37 @@ +#include "mbed.h" +#ifndef HEXLEDS_H +#define HEXLEDS_H + + +class HexLeds +{ +public: + HexLeds(PinName pin1, PinName pin2, PinName pin3, PinName pin4) : + _pin1(pin1), _pin2(pin2), _pin3(pin3), _pin4(pin4), + _Leds(pin1, pin2, pin3, pin4) { // Initalisierungsliste + + _pin1 = 0; // Initalisierung mit 0 + _pin2 = 0; + _pin3 = 0; + _pin4 = 0; + _Leds = 0; + } + + void input(void); + + void output(void); + + void hexOut(void); + + void printStatus(void); + +private: + BusOut _Leds; + DigitalOut _pin1; + DigitalOut _pin2; + DigitalOut _pin3; + DigitalOut _pin4; + int _Hexwert; +}; + +#endif \ No newline at end of file
diff -r 000000000000 -r e8fedaebc8e3 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jun 21 12:42:52 2018 +0000 @@ -0,0 +1,11 @@ +#include "mbed.h" +#include "HexLeds.h" + +HexLeds hexleds(LED1, LED2, LED3, LED4); + +int main() { + hexleds.input(); + hexleds.output(); + hexleds.hexOut(); + hexleds.printStatus(); +} \ No newline at end of file