Which pins should i use according to the following code & the arduino pro mini

Which pins should i use according to the following code & the arduino pro mini? Also is it possible to connect pin 3 and pin 10 the the servo signal cable simultaneously ? Or I am not getting the meaning of the code right ? Which pins were actually used here then according to your programming understanding of the code....

// inout for 16mhz arduino 
// timebase is timer1 running 0.5us resolution up to 0xA000
// servo output timer1 channel A & B pin9 & pin10
// PPMSUM input INT0 PIN2 or 
// Single channel INT0 & INT1 pin2 & pin3

#define PPM_FREQ 0xA000 //xA000 // 20ms
#define SERVOS 2 
#define RC_CHANNELS 5 

uint16_t servo[SERVOS]; 
volatile uint16_t rcValue[RC_CHANNELS];

#if defined(PPM_IN)
volatile uint16_t last_0;
volatile uint16_t last_1;

void rxInt0() 
{
  uint16_t now,diff; 
  now = TCNT1;
  if (!(PIND & 1<<2)) // we got a low on PD2
  {
    if (now >= last_0) diff = now - last_0;
    else               diff = now + PPM_FREQ - last_0;
    if (1800<diff && diff<4200) rcValue[0] = diff>>1; // 1000 - 2000
  }
  last_0 = now;
}

void rxInt1() 
{
  uint16_t now,diff; 
  now = TCNT1;
  if (!(PIND & 1<<3)) // we got a low on PD3
  {
    if (now >= last_1) diff = now - last_1;
    else               diff = now + PPM_FREQ - last_1;
    if (1800<diff && diff<4200) rcValue[1] = diff>>1; // 1000 - 2000
  }
  last_1 = now;
}
#endif

#if defined(PPMSUM) 
volatile uint16_t last_ppmsum;
volatile uint8_t chan = 0; 
  
void rxIntSum() 
{
  uint16_t now,diff;
  now = TCNT1;
  if (now >= last_ppmsum) diff = now - last_ppmsum;
  else                    diff = now + PPM_FREQ - last_ppmsum;
  if      (diff>6000) chan = 0; // Sync gap
  else if (chan < RC_CHANNELS)
  {
    if (1800<diff && diff<4200)
    {
      rcValue[chan] = diff>>1;
      chan++;
    }
    else chan = 20;
  }
  last_ppmsum = now;
}
#endif

void setupInput()
{  
  TCCR1A = (1<<WGM11);
  TCCR1B = (1<<WGM12) | (1<<WGM13);
  ICR1 = PPM_FREQ; // 20ms
  TCCR1B |= (1<<CS11);

  #if defined(PPM_IN)  
    pinMode( 2,INPUT);
    attachInterrupt(0, rxInt0, CHANGE); 
    pinMode( 3,INPUT);
    attachInterrupt(1, rxInt1, CHANGE); 
  #endif
  #if defined(PPMSUM) 
    pinMode( 2,INPUT);
    attachInterrupt(0, rxIntSum, FALLING); 
  #endif
  for (byte i=0;i<RC_CHANNELS;i++) rcValue[i] = 1500;  
}

void setupServo()
{
  pinMode( 9,OUTPUT);    
  pinMode(10,OUTPUT); 
  
  TCCR1A |= (1<<COM1A1); // connect pin  9 to timer 1 channel A
  TCCR1A |= (1<<COM1B1); // connect pin 10 to timer 1 channel B                                                                                                                                                     
  for(int i=0;i<SERVOS;i++) servo[i] = 1500; // 1,5ms
  writeServo();
}

void writeServo()
{
  OCR1A = servo[0]<<1; //  pin 9   PB5
  OCR1B = servo[1]<<1; //  pin 10  PB6
}

Pin 10 (and pin 9) are set up for output. Pin 3 (and pin 2) are set up for input. So, YES, pin 3 and pin 10 can be connected together. (Ditto for pin 2 and pin 9.)

A wiring diagram or wiring instructions would help. Code alone is not sufficient.

If I connect it like this using one servo only it would be ok or I will fry something ?
Should I change something ?

What is the easiest way to wire the arduino and the servo according to ur opinion then ?


There are at least two problems with the wiring that you pictured. (THANKS for the picture!)

  1. This diagram is not consistent with the code that was posted. Either the code will need to change or the wiring will need to change.

  2. You may connect your GPS to the RXD pin, but this pin is used for programming your Arduino, so you may need to disconnect the GPS while you are doing programming, and not do programming while you are using the GPS. This is going to get old very quickly.

Also, I do not know what "Pin 9 / Pin 10" is supposed to mean. If it means "either Pin 9 or Pin 10", then this could be satisfactory. If it means "connect Pin 9, Pin 10, and the Rud Servo together", then this would be a problem because both Pin 9 and Pin 10 are set up as outputs currently. Connecting together outputs is rarely good practice.

Good Luck!

Thanks for your help I will give it a go then and see what happens ..... one more thing if I connect pin 2 and 3 with one wire and then join them with the other wire coming from pin 10 would be ok or I will fry a pin ??? :sweat_smile:

Could anyone advice me on this last question mentioned in the above post please ???

You didn't answer some of the questions in it, so you should do that first. Your photos are extremely difficult to view the details. Can't you do better?

aarg:
You didn't answer some of the questions in it, so you should do that first. Your photos are extremely difficult to view the details. Can't you do better?
Which questions?

This one:

Also, I do not know what "Pin 9 / Pin 10" is supposed to mean. If it means "either Pin 9 or Pin 10", then this could be satisfactory. If it means "connect Pin 9, Pin 10, and the Rud Servo together", then this would be a problem because both Pin 9 and Pin 10 are set up as outputs currently. Connecting together outputs is rarely good practice.

... and where are the improved photos? It's nearly impossible to see anything in that nest of wires, at that fuzzy resolution.

Ok the GPS configuration is done at 115200 baud rate and 5Hz the Ledpin 13 was on and then off is that normal when home position is set or there is an error in the the way I did it ? I mean led pin 13 should stay on ?