Brian Jones / HeartBeat

Dependents:   ARM_DAY_PWM

HeartBeat.cpp

Committer:
mbj898
Date:
2012-11-30
Revision:
3:654a22520c76
Parent:
2:fc8dbf3231ee

File content as of revision 3:654a22520c76:

#include "mbed.h"
#include "HeartBeat.h"

HeartBeat::HeartBeat( PinName pwm) : pwmObject(pwm)
{
}


void HeartBeat::pwmIt(float frequency)
{
    float delay = frequency /100;
    
    if (delay < .001){
        delay = .003;
    }
    
    

    for(float p = 0.0f; p < 1.0f; p += 0.01f) {
        pwmObject = p;
        wait(delay);
    }

    for(float p = 1.0f; p > 0.0f; p -= 0.01f) {
        pwmObject = p;
        wait(delay);
    }


}