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.
Revision 0:ccb4d79a2cf7, committed 2016-08-15
- Comitter:
- satoyuki1111
- Date:
- Mon Aug 15 05:43:08 2016 +0000
- Commit message:
- POTENTIOMETER
Changed in this revision
encorder.cpp | Show annotated file Show diff for this revision Revisions of this file |
encorder.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r ccb4d79a2cf7 encorder.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/encorder.cpp Mon Aug 15 05:43:08 2016 +0000 @@ -0,0 +1,23 @@ +#include "encorder.h" +#include "mbed.h" + +Potentiometer::Potentiometer(PinName analog_) : analog(analog_) +{} +float Potentiometer::get_value() +{ + return float(analog.read()); +} +int Potentiometer::get_angle() +{ + return (int)(get_value() * 3600); +} +int Potentiometer::get_Rotation() +{ + return (int)Rotation; +} +int Potentiometer::get_angle2() +{ + Value = get_value()*10; + Rotation = Value; + return (int)((Value - Rotation)*360); +} \ No newline at end of file
diff -r 000000000000 -r ccb4d79a2cf7 encorder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/encorder.h Mon Aug 15 05:43:08 2016 +0000 @@ -0,0 +1,19 @@ +#ifndef MBED_ENCORDER_H +#define MBED_ENCORDER_H + +#include "mbed.h" +class Potentiometer +{ + private: + AnalogIn analog; + int Rotation; + float Value; + + public: + Potentiometer(PinName analog_); + float get_value(); + int get_angle(); + int get_Rotation(); + int get_angle2(); +}; +#endif \ No newline at end of file