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.
main.cpp
- Committer:
- Wizo
- Date:
- 2018-11-15
- Revision:
- 0:298c945518db
File content as of revision 0:298c945518db:
#include "mbed.h"
class MyLed {
public:
MyLed(PinName pin) : _pin(pin) { //Initialisierungsliste
_pin = 0; //Initialisierung mit 0
}
void ledOn(void) {
_pin = 1;
}
void ledOff(void) {
_pin = 0;
}
void printStatus(void){
printf("Read LED is now %d\n", _pin.read());
}
private:
DigitalOut _pin;
};
//DigitalOut led(LED1);
MyLed myled2(LED2); //Instanzierung des Objekts
MyLed myled5(p5);
int main() {
while (1) {
myled2.ledOn(); //Zugriff auf die Methode über "."-Operator
myled2.printStatus();
wait_ms(500);
myled2.ledOff();
myled2.printStatus();
wait_ms(500);
myled5.ledOn(); //Zugriff auf die Methode über "."-Operator
myled5.printStatus();
wait_ms(500);
myled5.ledOff();
myled5.printStatus();
wait_ms(500);
}
}