Ball gate sensor

Hi All.

This is my first post and my first foray into the world of programmers, electronics and programming.

I am trying to build a virtual bingo machine, it is like a flipper machine but instead of scoring points the bingo machines have 25 holes.

Usually you get one machine one game but a man named Joop has written software to be able to run an emulator on a computer and the base cabinet (the bottom with the 25 holes or the base with the flippers) as the mechanical side, so you have one base unit but 10 different machines at the minute with the emulation software.

My problem is the ball gate sensor which is a pair of metal contacts on a hinge, one side goes to a mega2650 and the other goes to ground, as the ball leaves the shooting lane and passes through the gate it opens the contacts but the mega doesn't seem to register it opening, I have found I have to hold it open longer for it to register, about 2 seconds.

My question is can I alter something in the sketch or do I need a different way of sensing the ball through the gate.

Cheers.
Ian.

Sounds like you have a "floating" input.

Chagrin:
Sounds like you have a "floating" input.

Or the sketch is not reading the pins quick enough.

Hi Guys.

Thanks for the replies.

It looks like my friend who wrote the sketch has already applied the input pull up.

I have pasted the first part of his sketch.

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(A2,INPUT_PULLUP); // Ball in lane
pinMode(A3,INPUT_PULLUP); // 8TH Ball
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);
}
}

Cheers.
Ian.

If you want help then you'll need to post the entire sketch.

Also please use code tags.

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);*

  • }*