void loop()//translate the number 0-9 to angle between 0 degree to 180 degree, and let LED blink the same times
{
    //val=4;
    printf("Enter with a angle value:\n");
    scanf("%d", &val);
    //val=val*(180/9);//translate number to angle
    for(int i=0;i<=50;i++)//wait enough time so that the servo can rotate to the specified angle
    {
        servopulse(servopin,val);//call the pulse function
    }
    for(int i=0;i<=50;i++)//wait enough time so that the servo can rotate to the specified angle
    {
        servopulse(servopin,0);//call the pulse function
    }
}
Example #2
0
/**
 * [UserServo description]
 * @type {[type]}
 */
void UserServo::write(int pulsewidth)
{
	for(int i=0; i<100; i++){
	    servopulse(pulsewidth);
	}	
}