control 20 RC servo motors using PC time

I am working on a project where i need to run 20 RC hobby servo motors in a set of 4 consist of 5 motors each.

the logic here is each set has to run by specific angle based on pc system time(H1H2:M1M2).
ranges for H1[0-2], H2 [0-9], M1[0-9],M2[0-9].

when i say time(say 23:47 ), for value of H1(2) one set of motor will run by 70 degrees and for H2(3) second set of motor will run by 35 degree.similarly for M1(4) third set and M2(7) forth set.

my challenge here is,

using processing-arduino mega

i can extract the system time in 24 hrs format and then get values for H1H2:M1M2 saperatly.
i get the current exact time each time the void loop runs.
but the problem am facing is how to control 20 servos.
from processing and arduino mega replica(it has only 2-13 PWM and 44-46 are not PWM or they are not working the level written is digital for 44-46) am able to control only 12 servos.

sample : arduino.analogWrite(pin, angle); pin[2-13]

how can i control the rest 8 servo motors.

using arduino

using the servo library
i can use the all the digital o/p ports to control 20 servo motors but the problem am facing is to get the time.
i read time functions, that returns no of seconds since jan 1970. but then how do i sync or get it refreshed with PC every time after uploading into arduino. more over i find it bit complex to understand.

can you please suggest some solutions.if i have missed some information let me know.please note am just a beginner.

thanks guys !

arduino mega replica(it has only 2-13 PWM and 44-46 are not PWM or they are not working the level written is digital for 44-46) am able to control only 12 servos.

No experience with servos or the following shield but you can use two Adafruit 16-Channel 12-bit PWM/Servo Shield - I2C interface

i can use the all the digital o/p ports to control 20 servo motors but the problem am facing is to get the time.

I don't understand; you said earlier you could get the time.

If you have code, please show it (using code tags).

PS
please start sentences with a capital letter; makes it easier it read.

Take the code that handles the time from the first code and put it in the code that uses the servo library and runs all 20 servos. I don't get what the problem is.

Why not send a message to the Arduino like this <aaa,bbb,ccc,ddd …> where aaa is the angle for the first servo, bbb is the angle for the second servo etc.

Have a look at the 3rd example and the parse example in Serial Input Basics

…R

Your assumption that you need to use PWM pins to control servos is wrong. Servos are controlled by PPM, not PWM. The Servo library handles setting up the timers to generate PPM output correctly, for any pin.

below is the code am trying to implement.

  1. Am using arduino mega and uploaded the servo lib into it.

  2. Running the code from Processing.

  3. My challenge is how to run 4 servo motors for H1 position [H1H2:M1M2] using which pins ? I tried between 22 to 53 they are not working. In the code i have just written [14-17] just for representation.

  4. H2,M1,M2 are are running perfectly as per my expectation.

  5. In arduino IDE using servo.write(pin) we have enough pin for all servo motors but problem there is minute(),second(),hour() throws error more over they are not real time read from PC in each loop if am not wrong.
    I also read about RTC and time.h lib but feel bit complicated.

  6. Any solution with the current implementation using processing IDE. Want to keep it as simple as possible.

//void setup
import processing.serial.*;
import cc.arduino.*;
 
Arduino arduino;
float h;
float m;
float s;
int h1;
int h2;
int m1;
int m2;
int s1;
int s2; 
int aftr_m1=99;
int aftr_m2=99;
int aftr_h1=99;
int aftr_h2=99;
void setup()
{

  // Prints out the available serial ports.
  println(Arduino.list());
  
  // change the array number acc to the serial starting from 0(COM21)
  arduino = new Arduino(this, Arduino.list()[2], 57600);

  
}
void disp_hour(int v_h1,int v_h2)
{

 if (aftr_h1!=v_h1)
 {
   //tens position of hour(H1) arduino pin[14-17]
  if(v_h1==0){  
		arduino.analogWrite(14, 10);arduino.analogWrite(15, 90);
		arduino.analogWrite(16, 90);arduino.analogWrite(17, 90);
	     }

  if(v_h1==1){ 
		arduino.analogWrite(14, 90);arduino.analogWrite(15, 10);
		arduino.analogWrite(16, 10);arduino.analogWrite(17, 10); 
	     }
  
  if(v_h1==2){ 
		arduino.analogWrite(14, 90);arduino.analogWrite(15, 10);
		arduino.analogWrite(16, 10);arduino.analogWrite(17, 90); 
	     }
  
  aftr_h1=v_h1;
 }

 if (aftr_h2!=v_h2)
 {
   //once position of hour(H2) arduino pin[10-13]
  if(v_h2==0){ 
		arduino.analogWrite(10, 10);arduino.analogWrite(11, 90);
		arduino.analogWrite(12, 90);arduino.analogWrite(13, 90); 
	     }
  
  if(v_h2==1){ 
		arduino.analogWrite(10, 90);arduino.analogWrite(11, 10);
		arduino.analogWrite(12, 10);arduino.analogWrite(13, 10); 
	     }
  
  if(v_h2==2){ 
		arduino.analogWrite(10, 90);arduino.analogWrite(11, 10);
		arduino.analogWrite(12, 10);arduino.analogWrite(13, 90); 
	     }

  aftr_h2=v_h2;
  
 }

}
void disp_min(int v_m1,int v_m2)
{

 if (aftr_m1!=v_m1)
 {
  //tens position of minute(M1) arduino pin[2-5]
  if(v_m1==0){ 
		arduino.analogWrite(2, 10);arduino.analogWrite(3, 90);
		arduino.analogWrite(4, 90);arduino.analogWrite(5, 90); 
	     }
  
  if(v_m1==1){ 
		arduino.analogWrite(2, 90);arduino.analogWrite(3, 10);
		arduino.analogWrite(4, 10);arduino.analogWrite(5, 10); 
	     }
  
  if(v_m1==2){ 
		arduino.analogWrite(2, 90);arduino.analogWrite(3, 10);
		arduino.analogWrite(4, 10);arduino.analogWrite(5, 90); 
	     }

  aftr_m1=v_m1;
 }

 if (aftr_m2!=v_m2)
 {
  //once position of minute(M2) arduino pin[6-9]
  if(v_m2==0){ 
		arduino.analogWrite(6, 10);arduino.analogWrite(7, 90);
		arduino.analogWrite(8, 90);arduino.analogWrite(9, 90); 
	     }
  
  if(v_m2==1){ 
		arduino.analogWrite(6, 90);arduino.analogWrite(7, 10);
		arduino.analogWrite(8, 10);arduino.analogWrite(9, 10); 
	     }
  
  if(v_m2==2){ 
		arduino.analogWrite(6, 90);arduino.analogWrite(7, 10);
		arduino.analogWrite(8, 10);arduino.analogWrite(9, 90); 
	     }
  
  aftr_m2=v_m2;
  
 }
}

void draw ()
{


h=hour();
h2=int(h%10);
h1=int(h/10);

m=minute();
m2=int(m%10);
m1=int(m/10);

s=second();
s2=int(s%10);
s1=int(s/10);

//println("m1:m2 ",m1+":"+m2);
disp_min(m1,m2);//pass tens,once place for minutes
disp_hour(h1,h2);//pass tens,once place for hour

}

Servos are NOT driven using PWM. They are driven using PPM. The servos do not have to be connected to PWM pins.

Use the version of Firmata that is for driving servos.