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.
You are viewing an older revision! See the latest version
Klasse PWM
Die folgende Klasse Rgb zeigt für eine Led die PWM am Beispiel RGB-Led des M0-Boards:
class Rgb {
PwmOut _red;
public:
Rgb( PinName red ) : _red(red) {}
void LedOn() {
//_red = 0;
for(float i=0.0; i <= 1.0; i+= 0.1) {
_red = i;
wait_ms(200);
}
}
void LedOff() {
_red = 1;
}
};
Rgb rgb(p36);
Im Vergleich zur DigitalOut Klasse hat sich eigentlich nur der "Datentype" von DigitalOut auf PwmOut verändert. Für die Methode LedOn wurde statt Zeile 6 das Dimmen der Led implementiert (Zeile 7-9). In Zeile 17 wird die rote Led der RGB-Led instaziiert.