Hi.
Here is the rest of the sketch.
Sorry but what are code tags.
|| This program is only for use with BALLY Bingo Backglass simulation by Joop.
|| The Bally bingo has a seperate switch which is attached to an input pin
|| to cater for the 25 holes
||
*/
// Table containing numbered hole codes for JR’s simulation
char Ballcodes [26] =
{’ ',‘A’,‘B’,‘C’,‘D’,‘E’,‘F’,‘G’,‘H’,‘I’,‘J’,
‘K’,‘L’,‘M’,‘N’,‘O’,‘P’,‘Q’,‘R’,‘S’,‘T’,‘U’,‘V’,‘W’,‘X’,‘Y’};
int BallsinPocket [26]; // slots 0 and 26 are not used
int sensorvalue;
char ch; // characters from Backglass
char ch1; // characters from button processor
void setup()
{
Serial.begin (9600);
Serial3.begin (9600);
//Set up the ARDUINO MEGA Pins
pinMode(2, INPUT_PULLUP); // YELLOW rollover
pinMode(3, INPUT_PULLUP); // RED rollover
pinMode(4, OUTPUT); // sets pin for YELLOW lamp output
pinMode(5, OUTPUT); // sets pin for RED lamp output
pinMode(A0,INPUT_PULLUP); // Ball thro gate
pinMode(A1,INPUT_PULLUP); // Ball return
pinMode(A8,INPUT_PULLUP); // Red New Game Button
pinMode(A9,INPUT_PULLUP); // Yellow Extra Ball Button
// Setup numbers 1 to 25 on pins 22 to 47 inclusive
for (int i=22; i <= 47; i++)
{
pinMode( i, INPUT_PULLUP);
}
}
void loop()
{
//
// Check for ball thro gate
sensorvalue = digitalRead(A0);
if (sensorvalue == LOW)
{
Serial.print (“z”);
delay(2000);
}
// Check for ball return
sensorvalue = digitalRead(A1);
if (sensorvalue == LOW)
{
Serial.print (“Z”);
delay (2000);
}
// Check if Red Button pressed for new game
sensorvalue = digitalRead(A8);
if (sensorvalue == LOW)
{
Serial.print (“n”);
delay (500);
Serial.print ("^");
delay (500);
for ( int i=1; i<26; i++)
{
BallsinPocket = 0;
-
}*
-
Serial.print ("^");*
-
} *
// Check if YELLOW button pressed for extra ball
-
sensorvalue = digitalRead(A9);*
-
if (sensorvalue == LOW)*
-
{*
-
Serial.print (“x”);*
-
delay (500);*
-
Serial.print ("^");*
-
}*
-
// read input from Slave UNO (Buttons)*
-
if (Serial3.available()>0) *
-
{*
-
ch1 = Serial3.read();*
-
Serial.print (ch1);*
-
delay (500);*
-
}*
-
//*
-
//Process commands from backglass*
-
//*
-
if (Serial.available()>0) *
-
{*
-
ch = Serial.read();*
-
Serial3.print (ch); //pass on to UNO*
-
// Check for Yellow Red lights ON or OFF*
-
// 7 Yellow ON 6 Yellow OFF*
-
// 5 Red ON 4 Red OFF*
-
if (ch == ‘7’ )*
-
{*
-
digitalWrite(4, HIGH);*
-
ch=’ ';*
-
}*
-
if (ch == ‘6’ )*
-
{*
-
digitalWrite(4, LOW);*
-
ch=’ ';*
-
} *
-
if (ch == ‘5’ ) {*
-
digitalWrite(5, HIGH);*
-
ch=’ ';*
-
}*
-
if (ch == ‘4’ )*
-
{*
-
digitalWrite(5, LOW);*
-
ch=’ ';*
-
}*
-
}*
// check for ball over YELLOW rollover
-
sensorvalue = digitalRead(2);*
-
if (sensorvalue == 0)*
-
{*
-
Serial.print (“8”); *
-
} *
// check for ball over RED rollover
-
sensorvalue = digitalRead(3);*
-
if (sensorvalue == LOW)*
-
{*
-
Serial.print (“9”); *
-
} *
*// check for ball in numbered hole *
-
for (int i=22; i <= 47; i++)*
-
{*
-
int sensorvalue = digitalRead(i); *
-
if ((sensorvalue) == LOW && (BallsinPocket [i-21]) == LOW)*
-
{ *
-
BallsinPocket [i-21] = 1;*
-
Serial.print(Ballcodes [i-21]);*
-
delay (250); *
-
Serial.print(Ballcodes [i-21]);*
-
}*
-
}*
-
delay (500);*
-
}*