Tadao Iida / Mbed 2 deprecated reflective1_rpm

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // --- reflective_rpm ---
00002 #include "mbed.h"
00003 #include "TextLCD.h"
00004 
00005 TextLCD lcd(p24, p26, p27, p28, p29, p30);
00006 InterruptIn count(p5)  ; 
00007 Ticker min ; 
00008 
00009 int cnt = 0;
00010 int rpm = 0;
00011 
00012 void count_r()
00013 {
00014     cnt++; 
00015 }
00016 
00017 void measure()
00018 {
00019     rpm = cnt * 5 ; 
00020 }
00021 
00022 int main() {
00023     lcd.cls();
00024     count.rise(&count_r); 
00025     min.attach(&measure ,3.0) ; 
00026     while(1) {
00027         lcd.locate(1,0);
00028         lcd.printf("rpm [%4d]",rpm) ;     
00029     }
00030 }