Simpson_Jr:
Depends on what the other options are.
Reading 6-8 keyboards at the same time with a single controller is probably quite difficult/complicated already. It may be possible, but I would probably need quite some time and aspirin to create a prototype that functions as it should. Being sure every bit of each board is read as it should will be quite complicated.
With a master/slave configuration you eliminate those problems, but you indeed introduce new ones, communication between master/slaves and type of network. Fortunately the device you want isn't too complicated (from a master/slave pov). It will take some time to get used to and to find the best type of network for your project, but what you need probably isn't much harder as most example-sketches for master/slaves. Advantage is also that you can find a lot of info/examples on working with master/slaves, while very few people will have read multiple keyboards with a single controller.
I tried to use change interrupts using (Google Code Archive - Long-term storage for Google Code Project Hosting.) and it works for one keyboard. It's harder to simulate using 6 keyboards at the same time with this method so I just have to test.
Here is the code:
/*
The keyboards clocks will be connected to a pin
that will report when will call a function when
the signal goes up.
This fucktion will read the data state of that keyboard
and if signal is complete sent it to the computer.
*/
#include <PinChangeInt.h>
#define MAX_KEYBOARDS 6
int g_scan_prog[MAX_KEYBOARDS]={0};
char g_scan_code[MAX_KEYBOARDS][11]={'0'};
char g_num_to_char_id[MAX_KEYBOARDS]={'a','b','c','d','e','f'};
int g_clk_pin_to_keyboard_id[12]={0,0,1,1,1,2,2,3,3,4,4,5};
int g_data_pins[MAX_KEYBOARDS]={2,4,6,8,10,12};
int g_clock_pins[MAX_KEYBOARDS]={0,3,5,7,9,11};
void clock_rise();
void setup()
{
Serial.begin(9600);
while(!Serial) ;
Serial.println("STARTUP DONE");
//init pins
for(int i=0;i<MAX_KEYBOARDS;i++)
{
pinMode(g_data_pins[i],INPUT);
pinMode(g_clock_pins[i],INPUT); digitalWrite(g_clock_pins[i], HIGH);
PCintPort::attachInterrupt(g_clock_pins[i], &clock_rise, RISING);
}
}
void loop()
{
;
}
void clock_rise()
{
int latest_interrupted_pin=PCintPort::arduinoPin;//to let function know which pin that called
int keyboard_id=g_clk_pin_to_keyboard_id[latest_interrupted_pin];
g_scan_prog[keyboard_id]++;
if( digitalRead( g_data_pins[keyboard_id] )==HIGH ) g_scan_code[ keyboard_id ][ g_scan_prog[keyboard_id] ]='1';
else g_scan_code[ keyboard_id ][ g_scan_prog[keyboard_id] ]='0';
//test if ready to send
if( g_scan_prog[keyboard_id]>=10 )
{
g_scan_code[ keyboard_id ][ 0 ]=g_num_to_char_id[ keyboard_id ];//set keyboard id
Serial.println( g_scan_code[keyboard_id] );//send
g_scan_prog[keyboard_id]=-1;//clear
}
}