Two leoanrdo's chained on one usb?

I want to chain two leonardos for total of 50 i/o's digital for a joystick. Dont want to do a matrix on one board. Anyways can i use a single usb cord on the main arduino to talk to the joystick library. while the second board only uses its usb connection for power.

You could certainly have a master Leo reading some joysticks and a second one reading some more and passing the data to the first one but how many joysticks can a single Leo read ? Surely not 25

by joystick i mean the joystick library interfacing buttons the leo has 25 i/o any digital in out output can be used for a button.

Are you sure about that ?

yup as per this diagram

I see pins 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, A0, A1, A2, A3, A4 and A5 for a total of 19 digital pins

Where are the others that take the total to 25 ?

0,1,2,3,4,5,6,7,8,9,10,11,12,13,SCL AND SDA on the right + A0,A1,A2,A3,A4,A5 + icsp 15,16,14. Total of 25. if two are used for chaining still 23 are left.

Don't suppose you noticed that SCL and SDA are just pins 3 and 2?

(Bill, are you really responsible for the errors in that diagram? :astonished:)

Are the SCl, SDA and the 3 ICSP pins addressable as separate digital pins or are they shared with other pins ?

so if i use sda and scl dedicated pins for chaining the bottom pins 3 and 2 would still be addressable right ? or are they shared ?

dont know about scl and sda but the icsp sure do seem to be addressable separately. i am not using mos,sci or whatever that is for anything. just need the arduino to build a simple button box.

This should help identify shared pins


void setup()
{
  Serial.begin(115200);
  while (!Serial);
  Serial.print("SDA\t");
  Serial.println(SDA);
  Serial.print("SCL\t");
  Serial.println(SCL);
  Serial.print("MOSI\t");
  Serial.println(MOSI);
  Serial.print("MISO\t");
  Serial.println(MISO);
  Serial.print("SCK\t");
  Serial.println(SCK);
  Serial.print("A0\t");
  Serial.println(A0);
  Serial.print("A1\t");
  Serial.println(A1);
  Serial.print("A2\t");
  Serial.println(A2);
  Serial.print("A3\t");
  Serial.println(A3);
  Serial.print("A4\t");
  Serial.println(A4);
  Serial.print("A5\t");
  Serial.println(A5);
}

void loop()
{
}

will try thanks

Or you can look at the schematic.

Works for me!

(Except for the little error. :grin:)

Pins 2 and 3 are the same as SCL and SDA, as you can see from your picture also: both are marked as Port PD0 ( pin3/SDA) resp. PD1 ( pin2/SCL )

Why is it a problem to use a I2C I/O expander like the MCP23017, which gives 16 additional I/Os per chip. I think that's much more easy than programming an additional Leonardo as I/O Expander - and at the end it does the same as the MCP23017.

i didn't know such boards existed. that would be much better

Well, both are not marked quite the same!

Adding a second microcontroller is almost always a bad idea! :roll_eyes: You then have to arrange all the protocols to make them cooperate. A port expander is a willing slave, much easier! :grin: