4180 lab 1

Dependencies:   mbed MCP23S17 PinDetect USBDevice

Committer:
emilywilson
Date:
Wed Jan 15 18:13:43 2020 +0000
Revision:
0:c1654e25cc43
parts 1-3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilywilson 0:c1654e25cc43 1 class RGBLed
emilywilson 0:c1654e25cc43 2 {
emilywilson 0:c1654e25cc43 3 public:
emilywilson 0:c1654e25cc43 4 RGBLed(PinName redpin, PinName greenpin, PinName bluepin);
emilywilson 0:c1654e25cc43 5 void write(float red,float green, float blue);
emilywilson 0:c1654e25cc43 6 private:
emilywilson 0:c1654e25cc43 7 PwmOut _redpin;
emilywilson 0:c1654e25cc43 8 PwmOut _greenpin;
emilywilson 0:c1654e25cc43 9 PwmOut _bluepin;
emilywilson 0:c1654e25cc43 10 };
emilywilson 0:c1654e25cc43 11
emilywilson 0:c1654e25cc43 12 RGBLed::RGBLed (PinName redpin, PinName greenpin, PinName bluepin)
emilywilson 0:c1654e25cc43 13 : _redpin(redpin), _greenpin(greenpin), _bluepin(bluepin)
emilywilson 0:c1654e25cc43 14 {
emilywilson 0:c1654e25cc43 15 //50Hz PWM clock default a bit too low, go to 2000Hz (less flicker)
emilywilson 0:c1654e25cc43 16 _redpin.period(0.0005);
emilywilson 0:c1654e25cc43 17 }
emilywilson 0:c1654e25cc43 18
emilywilson 0:c1654e25cc43 19 void RGBLed::write(float red,float green, float blue)
emilywilson 0:c1654e25cc43 20 {
emilywilson 0:c1654e25cc43 21 _redpin = red;
emilywilson 0:c1654e25cc43 22 _greenpin = green;
emilywilson 0:c1654e25cc43 23 _bluepin = blue;
emilywilson 0:c1654e25cc43 24 }