tac
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:3ba0b3ceda17
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Nov 21 19:02:44 2017 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" + +DigitalOut myled(LED1); + +AnalogIn ain(A0); //initialize input +Timer t; //initialize timer +float rpm; //declare rpm variable + +int main() { + + while(1){ //do always + if (A0 != 0){ //senses beam crossing + while (A0 == 0) { //no longer senses + t.start(); //start timer + } + t.stop(); //stop timer + rpm = t.read()*60; //obtain value of rpm + } + } + + + +}