Pinball Project

Bad news. Seems like two out of four functions on the Multiplexer/Driver Board are dead. The solenoid drivers are ok, but neither the multiplexer to the switch matrix nor the multiplexer/driver for the Bonus lamps work; some of the inputs are shorted. Remains to see if the other lamp drivers apart from the bonus array work.

Well well, I'll begin with making a new Multiplexer board just for the switch matrix. It's very simple and straightforward. Just a 7445 and some 1K2 pullup resistors for the switch lines in use. I don't have a 7445, but I can't see why one of my 7442's shouldn't do the same job.

Here's some code I have in mind for scanning the switch matrix. I'll use the same addresses, just to make it easier to refer to the manual. No debounching or any response to input yet.

// scan_switches.ino

const int bit0pin = 2;  //  MA41 (Black)
const int bit1pin = 3;  //  MA43 (Blue)
const int bit2pin = 4;  //  MA45 (Green)
// const int bit3pin = 5;  //  MA47 (Yellow) // Not needed?
const int Apin = 6;     //  JC09 Slate-White   or MA48
const int Bpin = 7;     //  JC10 Yellow-White  or MA46
const int Cpin = 8;     //  JC11 Red-White     or MA44
const int Dpin = 9;     //  JC12 Brown-White   or MA42

int ret;

void setup()
{
  pinMode(bit0pin, OUTPUT);
  pinMode(bit1pin, OUTPUT);
  pinMode(bit2pin, OUTPUT);
 //  pinMode(bit3pin, OUTPUT);  // Not needed?
  pinMode(Apin, INPUT);
  pinMode(Bpin, INPUT);
  pinMode(Cpin, INPUT);
  pinMode(Dpin, INPUT);
}

void loop()
{
  while(1)
  {
    ret = scansw();
    if(ret == 0) continue;
    if(ret == 1)  // Drain Pit Switch closed
    {
       // code...
    }
    // if(ret == ...) and so on...
  }
}


int scansw()
{
  // Scan Line 0
  digitalWrite(bit0pin, LOW);
  digitalWrite(bit1pin, LOW);
  digitalWrite(bit2pin, LOW);
  //  digitalWrite(bit3pin, LOW);  // Not needed?
  if(digitalRead(Apin) == LOW); return(1); // Drain Pit
  if(digitalRead(Bpin) == LOW); return(2); // Top Target
  if(digitalRead(Cpin) == LOW); return(3); // 50k Target
  if(digitalRead(Dpin) == LOW); return(4); // Top Pit

  // Scan Line 3
  digitalWrite(bit0pin, HIGH);
  digitalWrite(bit1pin, HIGH);
  if(digitalRead(Bpin) == LOW); return(32); // 500p Rollovers
  if(digitalRead(Cpin) == LOW); return(33); // 30p Contacts

  // Scan Line 4
  digitalWrite(bit0pin, LOW);
  digitalWrite(bit1pin, LOW);
  digitalWrite(bit2pin, HIGH);
  if(digitalRead(Bpin) == LOW); return(42); // 5k Rollovers, Bonus
  if(digitalRead(Cpin) == LOW); return(43); // Rollovers x2

  // Scan Line 5
  digitalWrite(bit0pin, HIGH);
  if(digitalRead(Apin) == LOW); return(51); // Left Drop Target
  if(digitalRead(Bpin) == LOW); return(52); // Center Drop Target
  if(digitalRead(Cpin) == LOW); return(53); // Right Drop Target

  // Scan Line 6
  digitalWrite(bit0pin, LOW);
  digitalWrite(bit1pin, HIGH);
  if(digitalRead(Apin) == LOW); return(61); // Left Bumper
  if(digitalRead(Bpin) == LOW); return(62); // Right Bumper
  if(digitalRead(Cpin) == LOW); return(63); // Left Slingshot
  if(digitalRead(Dpin) == LOW); return(64); // Right Slingshot

  // Scan Line 7
  digitalWrite(bit0pin, HIGH);
  if(digitalRead(Cpin) == LOW); return(73); // 30k Rollover
  if(digitalRead(Dpin) == LOW); return(74); // Top Slingshot
}