Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 8 months ago. This question has been closed. Reason: Unclear question
gwe
- include "mbed.h"
DigitalOut gpo(D0); DigitalOut led(LED_BLUE);
Serial pc(USBTX, USBRX);
InterruptIn InPin (D7); bool OutPin1 (D3); bool OutPin2 (D4);
volatile float period = 0; Timer periodTimer;
void interruptHandler(){ period=periodTimer.read(); periodTimer.reset(); }
int main() { periodTimer.start(); pc.baud(115200); InPin.rise(&interruptHandler); while(true){ printf("Period = %f Freq = %f\n",period,1/period); }
float freq = 1/period;
if (freq < 550) OutPin1 = true;
if (freq > 6950) OutPin2 = true;
}