#include <blinker.h>
#include <mapper.h>


#define PULSE           8     // Pulse, how long for pin to be high.
#define MIN_PERIOD    175     // Period, how long between high starts.
#define MAX_PERIOD    1000     



blinker  aBlinker(2,PULSE,MIN_PERIOD); 
mapper   periodMapper(0,1023,MAX_PERIOD,MIN_PERIOD);
float    currentPeriod;
bool     soundOn;

void setup() {

   Serial.begin(9600);
   soundOn = false;
   currentPeriod = -1;
   aBlinker.setOnOff(true);   // Fire it up. 
}


void loop() {

   float newPeriod;

   idle();
   newPeriod = periodMapper.map(analogRead(A0));
   if (newPeriod!=currentPeriod) {
      aBlinker.setPeriod(newPeriod);
      currentPeriod = newPeriod;
      Serial.print("B/Min :");
      Serial.println(60000/currentPeriod);
   }
   if (aBlinker.pulseHiLow()!=soundOn) {
      if (soundOn) {
         noTone(9);
      } else {
         tone(9,262);
      }
      soundOn = !soundOn;
   }
}
Period