yanami
Newbie level 4
Code:
void main()
{
int i;
ANSEL; // Configure AN pins as digital I/O
ANSELH;
PORTD;
TRISD;
RD2;
while(1)
{
//Move Anti Clockwise direction
for(i=1;i<=500; i++)
{
PORTD=(1<<RD2); //output_high(PIN_D2);
delay_us(1000); //want servo to move to 0 degrees.
PORTD=(0<<RD2); //output_low(PIN_D2);
delay_ms(20);
}
//Move Clockwise Direction
for(i=1;i<=500; i++)
{
PORTD=(1<<RD2); //output_high(PIN_D2);
delay_us(2000); //want servo to move to 180 degrees.
PORTD=(0<<RD2); //output_low(PIN_D2);
delay_ms(20);
}
}
}