pulseIn() perplexed.

So I am looking for a little guidance.. a little background: Sophomore EE student.. pretty bright, but I am a novice at programming. I have been trying to begin a project where I can use the Arduino to receive a frequency input. Not fast.. just 5V square wave.. probably no more than 100-200 Hz. Then I want to alter this frequency and send it back out on an output pin to drive a load.

I want to be able to adjust the frequency and pulse-width of the incoming pulse train, and then use the altered to drive the load.

So.. I've read up on the pulseIn() function and I am trying to utilize it to accomplish this. Read into the freqCounter library too.. but I can't find alot of good examples that I am able to digest mentally as the scope of my programming experience is limited.

I've tried working on some code using pulseIn(), but it has been a total flop.. I posted up some code a couple of days ago that doesn't even make sense to me now. Working and going to school full-time, and trying to experiment and code late at night works out great sometimes.. (if you don't realize the sarcasm.. I am injecting it now!)

So, anyways I have some code here that I think should work.. but doesn't. All I am trying to accomplish at this point is to create a faithful reproduction on an input signal. I've got a 5V p-p square wave going in on pin 7, and then I am attempting to use pulseIn() to read the high and low times and then use that to time a digitalWrite() function to send a pulse train out on pin 6.. but via my oscilloscope I am reading diddly on pin 6.

int frequencyOUT =  6;     
int frequencyIN = 7;
unsigned long durationHIGH;
unsigned long durationLOW;


void setup() 
  pinMode(frequencyIN, INPUT);
  pinMode(frequencyOUT, OUTPUT);

void loop()
  durationHIGH = pulseIn(frequencyIN, HIGH);
  durationLOW = pulseIn(frequencyIN, LOW);

  digitalWrite(frequencyOUT, HIGH);
  digitalWrite(frequencyOUT, LOW);

I would really appreciate some help with this guys.. if it is not feasible to do what I intend to I would really like to hear about some other options. Analog or digital! As for the code, in theory I really believe this should work, but I am missing something vital. Hope you all can spot it out!

Thanks all!

As a starting point, if you serial.print the 2 results, durationHIGH/LOW, are you getting back the values you expect?

"Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds. "

I would suggest that would result in this behavior:
pulseIn (HIGH) will start timing on the first rising edge, and stop timing on the first falling edge.
pulseIn(LOW) is then be called after the signal was already low, and waits for the following falling edge to start timing.
Your output signal would then go High, and Low, and then stay Low while the several cycles of pulses above get measured.


^ pulse in high start
^ pulse in high stops
^ pulse in low starts
^ pulse in low stops
^ high out starts
^ low out starts
^ next measurement starts

Output is thus delayed & divided down something like this:

What will "adjust the frequency and pulse-width of the incoming pulse train" and how will the output be altered?