PWM code to I2C code?

Hello guys,

I'm slowed down again in my project due to a problem, for my robot I brought an Arduino Uno and a servo shield to make the build a bit simple.

This one:

I tried for days using the example in the Servo lib to get my servos to swing:

/* Sweep
 This example code is in the public domain.
 modified 8 Nov 2013
 by Scott Fitzgerald

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position

But later I realised I need to use the specific library for the shield, as its I2C:

Now the problem I have is I cannot use the original code that was provided in the tutorial of this robot, and as I am only a beginner in coding, will someone be able to explain to me how I can get the original code to work with this shield, or how can I modify the original code to work with the shield?

This is the code I was meant to use to put servos in the correct position:

// Locate the initial position of legs 
// RegisHsu 2015-09-09

#include <Servo.h>   

Servo servo[4][3];

//define servos' ports
const int servo_pin[4][3] = { {2, 3, 4}, {5, 6, 7}, {8, 9, 10}, {11, 12, 13} };

void setup()
  //initialize all servos
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 3; j++)
  while (1);

void loop(void)

This is the main code for the robot: (the character count goes over the limit so I'll leave am link to it, sorry for causing inconvenience)

If anyone could help me by taking time to modify the following files(original code) to solve my problems I will be very grateful, or just help me in general.

Thanks everyone, very desperate for answers and help, my robot is due very soon for assessment, please help (>.<)/

I will also leave my email here if anyone wants to contact me that way.

->I just realised that the code is in PWM and I need to transform the code into I2C (:< how do I do it)
->The servos are not faulty, they work (I am using SG90 servos)
->If this helps, here is the instructables link:

Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile: