Tadao Iida
/
reflective1_rpm
エレキジャック Web版 マイコン・カーを製作してみよう<9>で紹介したモーターの回転数を測定するプログラムです。http://www.eleki-jack.com/arm/2012/05/9.html
Diff: main.cpp
- Revision:
- 0:6b5ea81c387d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 15 14:36:15 2012 +0000 @@ -0,0 +1,30 @@ +// --- reflective_rpm --- +#include "mbed.h" +#include "TextLCD.h" + +TextLCD lcd(p24, p26, p27, p28, p29, p30); +InterruptIn count(p5) ; +Ticker min ; + +int cnt = 0; +int rpm = 0; + +void count_r() +{ + cnt++; +} + +void measure() +{ + rpm = cnt * 5 ; +} + +int main() { + lcd.cls(); + count.rise(&count_r); + min.attach(&measure ,3.0) ; + while(1) { + lcd.locate(1,0); + lcd.printf("rpm [%4d]",rpm) ; + } +} \ No newline at end of file