Control LED brightness with analog in
Revision 0:127c030fa3ca, committed 2014-06-23
- Comitter:
- ethanharstad
- Date:
- Mon Jun 23 20:10:51 2014 +0000
- Commit message:
- First fader implementation
Changed in this revision
Fader.cpp | Show annotated file Show diff for this revision Revisions of this file |
Fader.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 127c030fa3ca Fader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Fader.cpp Mon Jun 23 20:10:51 2014 +0000 @@ -0,0 +1,9 @@ +#include "Fader.h" + +Fader::Fader(PinName in, PinName out) : _in(in), _out(out) { + _out.period(0.01); +} + +void Fader::update() { + _out = _in; +} \ No newline at end of file
diff -r 000000000000 -r 127c030fa3ca Fader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Fader.h Mon Jun 23 20:10:51 2014 +0000 @@ -0,0 +1,16 @@ +#ifndef FADER_H_ +#define FADER_H_ + +#include "mbed.h" + +class Fader { +public: +Fader(PinName in, PinName out); +void update(); + +private: +AnalogIn _in; +PwmOut _out; +}; + +#endif \ No newline at end of file