arduino manual pong table need help!

were using a arduino mega 1280 to control the solenoids using micro switches. how ever we can not get the relay switches to respond. we can control the solenoids using the breadboard manually. we have two micro switches going into digital input 22 and 24, 5v, and ground on the arduino. here is the code were using.

int microswitch1 = 22;
int microswitch2 = 24;
int solenoid1 = 26;
int solenoid2 = 28;

void setup()
{
// initialize the digital pin as an output.
pinMode(microswitch1, INPUT);
pinMode(microswitch2, INPUT);
pinMode(solenoid1, OUTPUT);
pinMode(solenoid2, OUTPUT);
}

void loop()
{

if (digitalRead(microswitch1)==HIGH)
{
digitalWrite(solenoid1,HIGH);
delay(1000);
}
else {
digitalWrite(solenoid1,LOW);
}

if (digitalRead(microswitch2)==HIGH)
{
digitalWrite(solenoid2,HIGH);
delay(1000);
}
else {
digitalWrite(solenoid2,LOW);
}

}

What sort of b buffers are you using to drive the solenoids?

What are B buffers. Solenoids are powered by a 12v power supply. Solenoids are connected to relays and the relays are controlled by the arduino.

Sorry, I have keyboard that stammers.
I meant buffers.

OK, so what buffers do you have on the relays?

What kind of relays are they? Most relays can not be triggered by the Arduino, because it doesn't output enough current from a digital pin. You might need a transistor to turn on the relay.

Groove:
Sorry, I have keyboard that stammers.
I meant buffers.

OK, so what buffers do you have on the relays?

Sorry but what are buffers?

PaulS:
What kind of relays are they? Most relays can not be triggered by the Arduino, because it doesn't output enough current from a digital pin. You might need a transistor to turn on the relay.

I dont know what kind they are but they are 5v relays that need about 600mA - 700mA. How many amps does the arduino output?

Arduino is only good for 40 mA max, will burn out after that.

How are the microswitches wired up?
Typically the internal pullups resistors are enabled:

pinMode(microswitch1, INPUT);
digitalWrite (microswitch1, HIGH); << with this statement.

If the switch is open, the input will be high, closing the switch then grounds the switch for a low reading.

One of the micro switches is connected to 5v and digital pin 22 as in input. The 5 volts of power is coming from the 5volts out on the arduino board. When the micro switch is pushed the arduino will read the 5v or High. This activates the 5v or HIGH out on pin26 for a sec. Pin 26 is connected to the control of the relay. The relay is used because the solenoid requires 12v. The relay allows us 12v from a different power supply to the solenoid.

The thing were trying to accomplish is that when the micro switch is hit the push solenoid will go off and hold that kick for a second and go back. Were trying to do this for two sets of solenods and microswitches.

Okay, try wiring the microswitch as I drew up the example. You don't describe anything that would make switch read as low, and you need to bring it to ground to get a good low.

Add Serial.begin, Serial.flush into your setup code, and Serial.println statements in your void loop, then you can confirm that you are actually seeing good highs & lows from your digitalReads.
Remember that the switches will have some mechanical bounce, you wil need to debounce them. Your delay(1000) would do that, if you had had pulldown resistors on the input pins, which you haven't described.

Add Serial.begin, Serial.flush into your setup code,

Not Serial.flush(). Serial.flush() empties the input buffer, which is not set up until Serial.begin() completes. There is no reason to flush an empty buffer.

Serial.flush() should rarely need to be used at all, and only when you really understand what it is doing, and why the stuff in the input buffer should be trashed instead of read.

Good point out PaulS. I regularly just put it in to make sure I don't forget it for the times I do need it.

I regularly just put it in to make sure I don't forget it for the times I do need it.

The thing is that there are so few times when you DO need to flush the unprocessed incoming data that you should have to THINK to include it. You'll think to include it because the condition is so rare.

CrossRoads:
Okay, try wiring the microswitch as I drew up the example. You don't describe anything that would make switch read as low, and you need to bring it to ground to get a good low.
Serial - Arduino Reference
Add Serial.begin, Serial.flush into your setup code, and Serial.println statements in your void loop, then you can confirm that you are actually seeing good highs & lows from your digitalReads.
Remember that the switches will have some mechanical bounce, you wil need to debounce them. Your delay(1000) would do that, if you had had pulldown resistors on the input pins, which you haven't described.

Okay from what I understand I need to put Serial.begin in my setup code at 9600? And I don't need a Serial.flush in our setup code? I don't get how Serial.print in is going to be used here. Thank you for the schematics that you drew for us, originally we did not have any pulldown resistors on the input pins. What value resistors should we use?

Okay from what I understand I need to put Serial.begin in my setup code at 9600?

Yes, you do.

And I don't need a Serial.flush in our setup code?

No, you don't.

I don't get how Serial.print in is going to be used here.

Any place where it might be interesting to know what is happening, use Serial.print to send a message to the serial monitor.
if (digitalRead(microswitch1)==HIGH)
{
Serial.println("Switch 1 is HIGH");

Then, in the serial monitor, if you see "Switch 1 is HIGH" right after you press the switch, you know that the switch is being read correctly.

You can use this technique to print values, too:
int val = analogRead(A0);
Serial.print("A0 value: ");
Serial.println(val);

Pull down resistor, values like 1K, 2K would do it.