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.
Klasse PWM
Die folgende Klasse Rgb zeigt für eine Led die PWM am Beispiel RGB-Led des M0-Boards (M3Board siehe Application-Board):
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); // M3Board r: p23 g: p24 b: p25;
Im Vergleich zur HasA-Klasse für DigitalOut 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 als Objekt rgb instaziiert.