need help to convert from PIC code to Arduino code

please someone convert this code and send it back to me because i tried and i can’t make it work !!!

sbit PWM at portd.b1;

unsigned int V_in; //volt_input AN1
unsigned int V_ZC; //zero_cross AN3

int x,flag=0;
void main() {
trisd=0;
portd.b1=1;
delay_ms(1000);

while(1){
flag=0;
if(adc_read(3)>800){
delay_us(10);
V_in=adc_read(1);
PWM=0;
if(V_in>900){PWM=0;delay_ms(8);flag=1;}
if((V_in<=880)&&(flag==0)){
for(x=0;x<V_in;x++){delay_us(10);}
PWM=1;
delay_us(10);
PWM=0;
}
}
}
}

Just use the PIC instead.

adc_read() sounds like the equivalent of analogRead(). http://arduino.cc/en/Reference/analogRead

BTW, it is bad practice to read a port during a test. Better to read all the inputs and then perform all tests on the stored values.

delay_ms() would merely be delay(), although I don't like using delay(). http://arduino.cc/en/Reference/Delay

delay_us() is delayMicroseconds(). http://arduino.cc/en/Reference/DelayMicroseconds

Why you shouldn't use delay(): http://playground.arduino.cc/Code/AvoidDelay

It looks like PWM would be analogWrite() on the Arduino, and you just select a value between 0 (0% duty cycle) and 255 (100% duty cycle). The Arduino is picky about which pins analogWrite() works with. http://arduino.cc/en/Reference/analogWrite

Look in my signature for links to how to use millis() and micros() timers to avoid using delay().

while works differently, I think.

http://arduino.cc/en/Reference/While

http://arduino.cc/en/Tutorial/WhileLoop

polymorph: while works differently, I think.

http://arduino.cc/en/Reference/While

http://arduino.cc/en/Tutorial/WhileLoop

I can't think of any language where "while" differs significantly.