WattsThat:
No idea because I cannot see your program. No one can on a mobile or a pad when you attach it rather than posting it correctly using code tags, the </> icon.
Why did you abandon this thread, it looks like the same program and topic.
Problem starting with Arduino Uno - #570719 - Uno Punto Zero - Arduino Forum
Perhaps you should read/review the posting rules: How to use this forum
Again mate I'm new to this, I don't really know what I'm doing yet as I haven learnt and I reposted as I couldn't find the original thread, it just so happened someone replied allowing me to find it again.
but here's the code if your going to help me thanks in advance!
<// constants won't change. They're used here to set pin numbers:
const int button1Pin = 2; // the number of the pushbutton1 pin
const int button2Pin = 4; // the number of the pushbutton2 pin
const int relay1Pin = 7; // the number of the Realy1 pin
const int relay2Pin = 8; // the number of the Relay2 pin
// variables will change:
int button1State = 0; // variable for reading the pushbutton status
int button2State = 0; // variable for reading the pushbutton status
const int sensorPin = 0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
//start serial connection
Serial.begin(9600);
// initialize the pushbutton pin as an input:
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
// initialize the relay pin as an output:
pinMode(relay1Pin, OUTPUT);
pinMode(relay2Pin, OUTPUT);
}
void loop(){
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
//print out the value of the pushbutton
Serial.println(sensorValue);
// read the state of the pushbutton values:
button1State = digitalRead(button1Pin);
button2State = digitalRead(button2Pin);
// check if the pushbutton1 is pressed.
// if it is, the buttonState is HIGH:
// we also ensure tha the other button is not pushed to avoid conflict
if (button1State == HIGH && button2State == LOW) {
// turn relay1 on:
digitalWrite(relay1Pin, HIGH);
}
// When we let go of the button, turn off the relay
else if (digitalRead(relay1Pin) == HIGH) {
// turn relay1 off:
digitalWrite(relay1Pin, LOW);
}
// repeat the same procedure for the second pushbutton
if (button1State == LOW && button2State == HIGH) {
// turn relay2 on:
digitalWrite(relay2Pin, HIGH);
}
// When we let go of the button, turn off the relay
else if (digitalRead(relay2Pin) == HIGH) {
// turn relay2 off:
digitalWrite(relay2Pin, LOW);
}
}//>