ver1
Dependents: 2018NHK_gakugaku_robo 2018NHK_gaku_ver2
Revision 0:f7772ceff8e9, committed 2018-08-21
- Comitter:
- tanabe2000
- Date:
- Tue Aug 21 11:07:19 2018 +0000
- Commit message:
- ver1
Changed in this revision
lineSensor.cpp | Show annotated file Show diff for this revision Revisions of this file |
lineSensor.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r f7772ceff8e9 lineSensor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lineSensor.cpp Tue Aug 21 11:07:19 2018 +0000 @@ -0,0 +1,29 @@ +#include "lineSensor.h" + +lineSensor::lineSensor(PinName line_):linevalue(line_) +{ + assembleTicker.attach(callback(this, &lineSensor::lineassemble),0.01); +} + +void lineSensor::lineborder(float border_) +{ + border = border_; + } + + +void lineSensor::lineassemble() +{ + line = linevalue.read(); + line *= 3300; + } + +float lineSensor::rawlinevalue() +{ + return line; + } + +bool lineSensor::getJudgment() +{ + if(line > border) return 1; + else return 0; + } \ No newline at end of file
diff -r 000000000000 -r f7772ceff8e9 lineSensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lineSensor.h Tue Aug 21 11:07:19 2018 +0000 @@ -0,0 +1,45 @@ +#ifndef LINE_SENSOR +#define LINE_SENSOR + +#include "mbed.h" + + +/** + * ラインセンサ用クラス + */ +class lineSensor{ +public: + /** + * デフォルトコンストラクタ + */ + lineSensor(PinName line_); + + /** + *ラインとの境目の位置 + */ + void lineborder(float border_); + + + /** + *ラインの判別表示 + *1だとライン踏んでいる + *0だとラインを踏んでいない + */ + bool getJudgment(); + + /** + *センサの値表示 + */ + float rawlinevalue(); + +private: + AnalogIn linevalue; + float line, border; + Ticker assembleTicker; + void lineassemble(); + +}; + + + +#endif