• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeRobotUse SG90 servo on pcDuino3
Previous Next

Use SG90 servo on pcDuino3

Posted by: admin , October 24, 2014

SG90 is a mini servo. In this post, we will show how to use pcDuino3 to control SG90.
servo_for_web_cam__20584.1398809804.1280.1280

 

pcDuino3 can directly control SG90 using the GPIO pins as shown in post.  In this post, we will how to control SG90 using the Linker servo module.

Linker Servo Module is connected to the Linker Base Shield on [D1 D2 V S], which is installed on pcDuino3. The picture of the whole setup is shown below:

1024_2

 

The code used in the Arduino-ish programming is shown below:

#include <core.h>
 
void setup()
{
  Serial.begin(9600);
  delay(100);
}
 
unsigned int i;
 
void loop()
{
   //cammand : S + PWM + Duty_H + Duty_L + E
   for(i=100;i<450;i++)
   {
     //PWM 1
     Serial.print('S');   //Start
     Serial.print(char(1)); //PWM channel selection
     Serial.print(char(i/0xFF)); //Duty HIGH
     Serial.print(char(i%0xFF)); //Duty LOW
     Serial.print('E'); //End
 
   }
 
    for(i=450;i>100;i--)
   {
     Serial.print('S');
     Serial.print(char(1));
     Serial.print(char(i/0xFF));
     Serial.print(char(i%0xFF));
     Serial.print('E');
     delay(5);
   }
}

When it runs, we can set SG90 rotate to continuous positions:

Share!
Tweet

admin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors