How to create a code in arduino ?

Hi, I'm a newbie with Arduino and I wanted to ask how to write a code. I have connected 2 motors with l293d and need do a sequenze like this :

Read ultrasonic sensor (r=distance in cm )

if (r>4) motor 1 and motor 2 High else motor 1 OR motor 2 High for "t " seconds

when "t" seconds ends motor1 and motor 2 High

loop sequence .

Start by looking at the examples in the iDE to see the required structure of an Arduino sketch, then look at the Sensors/Ping example to see how to use that sensor.

I do not know what sensor you are using, but when you purchase from Arduino, Adafruit, Sparkfun and other dealers you should have access to sample sketches like:

If not, and it is a common sensor, a Google search is often rewarding:

Your pseudo code is quiet good, translating to real Arduino syntax will not be too difficult. You start by reviewing the core instructions: Then drill down to review the command details.

So, I would start with working code for the ultrasonic unit, ADD my code to control 2 LEDs instead of the motors. Get all of that working and then work with adding in the motor logic.