<p>Note: I have extended my question as some of you mentioned that the question is not clear.</p>

<p>I am using a RAMPS 1.4 board with an Arduino mega 2560. I need to drive a stepper motor as an extruder using either E0 or E1. I am using Repetier-Firmware and can drive the extruder (stepper motor) using the E0 (RAMPS 1.4). 
Now for my application, I need to make sure that the extruder is in home position before it starts to drive for the very first time. I am trying to use a  switch to connect to the end stop and perform this homing operation. I can do this for X, Y, and Z axes. I was wondering how (h/w connections and firmware modification) can I do it for the extruder?</p>

The edited question
appears to mention that
the actual extruders of the print head need to home / limit themselves
. The answer is that this is not required. When operating direct or Bowden driven extruder setups, you know (or you can measure or find out experimentally) the distance that the filament has to travel from extruder entry to hot end (e.g. to load new filament). If already loaded, because you have printed before, you also know where the filament is (filament could stop after printing, personally I retract the filament en few mm after a print). When a new print starts you usually reverse the retraction at temperature and extrude some extra filament to prime the nozzle to counteract oozed out filament for instance. At that point, the nozzle is primed and the gcode G92 E0 is then used to tell the extruder this is the start at zero length, sort of the home position of the filament. All this is usually done in the start code of your slicer, similar to  disabling bed and hot end temperature or final retract is done in the end code of your slicer.
This answer below addresses the initial question
, this question was not quite clear. It was
phrased as of the head containing the extruders needed to be homed correctly
. The normal end-stops (can be mechanical or optical switches) already ensure that the printer head (containing the extruder or extruders) is homed correctly (if correctly configured in your printer firmware). The home offsets you define in the firmware define that you start at the origin (0,0,0).
Your question does not state what firmware you use, but e.g. in Marlin firmware these settings are found in the
firmware configuration file
.
In this file the following is defined:
```
```
// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS 0
#define Y_MIN_POS 0
```
```
These values must be changed according to the offset between your switch and the origin of the heat bed (e.g. Prusa style printers have the origin at the front left).
For my Prusa clone printer I have defined:
```
```
// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS -35
#define Y_MIN_POS -12
```
```
What this says is that the homing switch for the X axis is 35 mm left of the origin, etc.