Problem with a simple sketch

Hello Arduino Users!

I am a Arduino newbie. First I have play with several codes and it is working :)

Now I have a ( I think) simple problem. I have built a model cableway and the idea is to shuttle the cabins between the 2 stations. I made this code:

#define RELAY1   6                        
#define RELAY2   7                        
#define BUTTON1  8                        
#define BUTTON2  9

void setup()
// Initialise the Arduino data pins for OUTPUT
  pinMode(RELAY1, OUTPUT);      
  pinMode(RELAY2, OUTPUT);
  pinMode(BUTTON1, INPUT);
  pinMode(BUTTON2, INPUT);

void loop()

      digitalWrite(RELAY1,LOW);           // Turns ON Relays 1
      delay(10000);                       // Wait 10 seconds
      digitalWrite(RELAY2,HIGH);          // Turns Relay Off
      digitalWrite(RELAY2,LOW);           // Turns ON Relays 1
      delay(10000);                       // Wait 10 seconds
      digitalWrite(RELAY1,HIGH);          // Turns Relay Off

I use 2 relays to change the motor direction. Thats working. (Relay 1: forward, relay 2: back)

The idea is that the cabin touch the button, wait 10 seconds and return. I have plugged in the buttons between GND and Port 8 and 9, but when I connect for example Port 8 with GND, nothing happend :( I think I'm doing something wrong but I don't know what the problem is. Can anybody help me to fix this problem?

Best regards,



BUTTON1 has the value 8. 8 is always true

You need to digitalRead() the buttons to get their states rather than use the value of the button pins themselves.