Step motor control

I want a code to control a stepped motor. Controlling in such a way that it would rotate half and return back. Help me in this regard

These links should help get you started.

Stepper Motor Basics Simple Stepper Code

If you need more help please post a link to the datasheet for your stepper motor and tell us what stepper motor driver you are using.

...R

While you're at it, perhaps explain what this actually means:

Kamlesh_1821me03: rotate half

A 200 step motor driven with full steps would need 100 steps to rotate 180 degrees, or, if say at x8 microstepping would require 800.

So details of your hardware are important - any information you have about this will help lead to useful accurate answers...

Look at the Stepper_h library examples. There is a sketch that drives a stepper 360° Cw and then 360° CCW until you remove power.