9 years, 8 months ago.  This question has been closed. Reason: Unclear question

gwe

  1. 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;

}

Question relating to:

Lab 5 creates a frequency read and programs a motor driver