
Lab3 Part
RGB_LED.h@1:ff9797f5be2c, 2018-01-30 (annotated)
- Committer:
- Nydrel
- Date:
- Tue Jan 30 22:42:11 2018 +0000
- Revision:
- 1:ff9797f5be2c
- Parent:
- 0:02946956d93e
Changed main while loop -- inverted redOn, blueOn, greenOn
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bjs9 | 0:02946956d93e | 1 | #include "mbed.h" |
bjs9 | 0:02946956d93e | 2 | |
bjs9 | 0:02946956d93e | 3 | class RGBLed |
bjs9 | 0:02946956d93e | 4 | { |
bjs9 | 0:02946956d93e | 5 | public: |
bjs9 | 0:02946956d93e | 6 | RGBLed(PinName redpin, PinName greenpin, PinName bluepin); |
bjs9 | 0:02946956d93e | 7 | void write(float red,float green, float blue); |
bjs9 | 0:02946956d93e | 8 | private: |
bjs9 | 0:02946956d93e | 9 | PwmOut _redpin; |
bjs9 | 0:02946956d93e | 10 | PwmOut _greenpin; |
bjs9 | 0:02946956d93e | 11 | PwmOut _bluepin; |
bjs9 | 0:02946956d93e | 12 | }; |
bjs9 | 0:02946956d93e | 13 | |
bjs9 | 0:02946956d93e | 14 | RGBLed::RGBLed (PinName redpin, PinName greenpin, PinName bluepin) |
bjs9 | 0:02946956d93e | 15 | : _redpin(redpin), _greenpin(greenpin), _bluepin(bluepin) |
bjs9 | 0:02946956d93e | 16 | { |
bjs9 | 0:02946956d93e | 17 | //50Hz PWM clock default a bit too low, go to 2000Hz (less flicker) |
bjs9 | 0:02946956d93e | 18 | _redpin.period(0.0005); |
bjs9 | 0:02946956d93e | 19 | } |
bjs9 | 0:02946956d93e | 20 | |
bjs9 | 0:02946956d93e | 21 | void RGBLed::write(float red,float green, float blue) |
bjs9 | 0:02946956d93e | 22 | { |
bjs9 | 0:02946956d93e | 23 | _redpin = red; |
bjs9 | 0:02946956d93e | 24 | _greenpin = green; |
bjs9 | 0:02946956d93e | 25 | _bluepin = blue; |
bjs9 | 0:02946956d93e | 26 | } |
bjs9 | 0:02946956d93e | 27 | //class could be moved to include file |
bjs9 | 0:02946956d93e | 28 | |
bjs9 | 0:02946956d93e | 29 | |
bjs9 | 0:02946956d93e | 30 | //Sestup RGB led using PWM pins and class |