Pulse generator?

HI all. I want to make a programmable pulse generator using Arduino. The "specifications" I need are the following: A) first output generates 10 usec pulse with frequency 10 Hz. B) One "enable" input. When it goes high all others pulses get generated. All following pulses are generated once with relative delay to the first pulse A after B went high. C) 10 usec pulse with variable 10-200 usec delay D) 5-20 msec pulse with delay from 1 msec to 20 sec. All pulses are TTL. I would like to set up (throuhg comport or LPT port or USB) delay of pulse C, delay and width of pulse D.

Is it possible to do with one arduino uno board without a shield. Thank in advance for any advise where to start.

Start reading the tutorial section - http://www.arduino.cc/en/Tutorial/HomePage - and the reference section - http://arduino.cc/en/Reference/HomePage

especially while() micros() digitalRead() and digitalWrite() and last but not least the blink without delay example (reference page)

Here is a script I use to do pulse width modulation for a electroplating tank
the pulse width is determined by a potentiometer to the analog in.

You could just as well control it with input from the USB port. There are lots of sample of how to do this in the Forum

// set pin numbers:
 int platepin = 2;
 int plateGrnd =3;
 int unplatepin =4;
 int unplateGrnd=5;
 int DutyHi;
 int DutyLo;    
float DutyRatio; 
void setup() {
  // set the digital pin as output:
  pinMode(13, OUTPUT);  
  pinMode(2, OUTPUT);
  pinMode(3,OUTPUT); // go low when 6 is high 
  pinMode(4, OUTPUT);  
  pinMode(5, OUTPUT);// go low when 7 is high
void Sequence_plating()
  delay(10 *DutyHi/1023);
  digitalWrite(platepin, LOW);
  digitalWrite(unplatepin, HIGH); 

void Get_Ratio()
    DutyHi = analogRead(0);
    DutyLo = 1023; //analogRead(1);
    DutyRatio = (DutyHi+1/(DutyLo+1)); // 1023/0 max
    if ( DutyHi <= 700) // warn that duty cycle is approching unplating

void loop()

first output generates 10 usec pulse with frequency 10 Hz.

for such short pulses you might need to take a look at the hardware timers - google playground timer arduino

Furthermore direct port manipulation might be needed for this kind of speed .

i want to create pulse with tH=1us and TL=XXms....frequency 1MHZ,,,it is possible?

I would write a separate sketch for that and do the pulse 1us in assembly.
Google direct port manipulation to set the line HIGH and LOW
and use NOP (assembler instruction) to get length exact 1 usec

http://www.avr-tutorials.com/assembly/calculating-execution-time-code-single-loop http://www.avr-tutorials.com/assembly/calculating-execution-time-code-double-loop

AVR delay calculator: http://electronics-lab.com/downloads/mcu/003/index.html

first output generates 10 usec pulse with frequency 10 Hz.

  1. loop start: pin high
  2. 158 cycles
; ============================= 
;    delay loop generator 
;     158 cycles:
; ----------------------------- 
; delaying 156 cycles:
          ldi  R17, $34
WGLOOP0:  dec  R17
          brne WGLOOP0
; ----------------------------- 
; delaying 2 cycles:
; =============================
  1. pin low (160cycles = 10usec)
  2. 100ms period - we need (1.600.000 - 160) cycles (maybe minus 1 or 2 because of the loop)
; ============================= 
;    delay loop generator 
;     1599840 cycles:
; ----------------------------- 
; delaying 1599831 cycles:
          ldi  R17, $1B
WGLOOP0:  ldi  R18, $4F
WGLOOP1:  ldi  R19, $F9
WGLOOP2:  dec  R19
          brne WGLOOP2
          dec  R18
          brne WGLOOP1
          dec  R17
          brne WGLOOP0
; ----------------------------- 
; delaying 9 cycles:
          ldi  R17, $03
WGLOOP3:  dec  R17
          brne WGLOOP3
; =============================
  1. loop end

Not tested, just calculated :) :)