how to use tower pro micro servo 9g sg90

how to use tower pro micro servo 9g sg90 with arduino ?

Hi,
It's simple! there are lots of examples on line, try Arduino playground.

Here's a bit of code from one of my robot sketches.

.

 #include <FastIO.h>
 #include <I2CIO.h>
 #include <LiquidCrystal_I2C.h>
 #include <Wire.h>
 LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3, POSITIVE);  // Set the LCD I2C address  
 Define constants and varibles
*/
 #include <Servo.h> 
 
const int LMpwm=6,LMdir=8,RMdir=7,RMpwm=9;  //Motor pins 
int distance,cm,FRQ,TD,A,B,MotorTime,switches,action,Lspeed,Rspeed,Tilt;
long int randNumber,motorSpeed,TwirlTime;
float unit,val,bv,factor;
boolean go; 
Servo servoScan;

void setup()
{ 
//	lcd.begin(16,2);
//	battCheck();
//	lcd.clear();
//	lcd.setCursor(2,0);
//	lcd.print("I am Waiting");
	delay(1000);
//	lcd.setCursor(3,1);
//	lcd.print("Wave me off");
	pinMode(LMpwm, OUTPUT);      // sets the digital pin as output     
	pinMode(LMdir, OUTPUT);      // sets the digital pin as output
	pinMode(RMdir, OUTPUT);      // sets the digital pin as output      
	pinMode(RMpwm, OUTPUT);      // sets the digital pin as output
	go = true;
	Lspeed=200;
	Rspeed=200;
    servoScan.attach(A0);
    servoScan.write(90);
    delay(200);
    scan();
}

// * * * start of Main program * * * *

void loop()
{

So you have to #include the library <Servo.h>
Attach it to a I/O pin with servoScan.attach(A0); Any pin will do!
and tell it where to move to with servoScan.write(90); values 0-180 approx?

Just play around with that see what happens......

Hope it helps.

Mel

Look at the Servo/Knob and Servo/Sweep sketches included in IDE. They cover the basics of driving a servo and the SG90 is an ordinary servo.

Just don't try to power more than one servo from the Arduino board itself. Servos can take a lot of current so it's best to use a separate power supply for them.

Steve

thank you