Pulse Out library

this is my first one,

I’ve learned a lot with this forum and I would like to contribute with a library that I’ve made to pulse a pin.
It has some functions to pulse a pin in different ways.

PulseH(long); //H → t → L
PulseL(long); //L → t → H
PulseHVar(long, long); //H → t1 → L → t2
PulseLVar(long, long); //L → t1 → H → t2
PulseTrain(long, long); //H → t → L → t → H for n times
PulseTrainVar(long, long, long); //H → t1 → L → t2 → H for n times

hey!, everything stated with the Blink project.
I hope you enjoy and thanks for all.

PulsePlus.7z (1.33 KB)

thanks for sharing, a good start

a few comments:

pulseplus.h.cpp should be named pulseplus.cpp That is the standard naming convention (pulseOut is imho an even better name)

int pin -> uint8_t pin (using 1 byte instead of 2)

you use delay extensively, but the parameter type of delay is [u]unsigned[/u] long, so you should use unsigned long in your interface. Prevents negative values !! furthermore you should mention that the code is blocking

missing option to switch between delay() and delaymicros() ?

codesize can be minimized as functions are quite similar e.g. PulseH(long); //H -> t -> L PulseL(long); //L -> t -> H

void PulseOut(uint8_t startMode, unsigned long duration)
{
  digitalWrite(_pin, startMode);
  delay(duration);
  digitalWrite(_pin, !startMode);  // ! is inverted value
}

other member functions pop up. how about a

void PulseOutRandom(uint8_t startMode, unsigned long maxDuration)
{
  digitalWrite(_pin, startMode);
  uinsigned long duration = random(maxDuration);
  delay(duration);
  digitalWrite(_pin, !startMode);  // ! is inverted value
}

Did something related - http://forum.arduino.cc/index.php/topic,139407.0.html -