FSST - Hardwarenahe Programmierung

Lösung DigitalAus1

#include "mbed.h"
 
class DigitalAus : public DigitalOut
{
    public:
    DigitalAus(PinName ld) : DigitalOut(ld,0){}
    
    int lese() {
        return read();
    }
    void schreibe(int value) {
        write(value);
    }
    using DigitalOut::write;

    void write(int value, bool t) {
        printf("Ätsch");
    }

    void blink10Mal(int zeit) {
        int i=0; 
        while( i < 10) {
            write(1);
            wait_ms(zeit);
            write(0);
            wait_ms(zeit);
            i++;
        }
    }        

    void blink10Mal() {
        int i=0; 
        while( i < 10) {
            write(1);
            wait_ms(500);
            write(0);
            wait_ms(500);
            i++;
        }
    }
};
 
DigitalAus led(LED1);
 
int main() {
    printf("Blink 10 Mal\n");
    led.blink10Mal(100);
    printf("Blink 10 Mal end\n");
    
    while (1) {
        led.write(0);
        printf("Blink! LED is now %d\n", led.read());
        wait_ms(500);
            
        led.write(1);
        printf("Blink! LED is now %d\n", led.read());
        wait_ms(500);
    }
}

All wikipages