Can someone please help me with this program problem? I need to be able to read 3 different digital inputs to give 2 outputs an example would be:
Input 1 = HIGH
Input 2 = HIGH
Input 3 = LOW
Output 1 = LOW
Output 2 = HIGH
I need it to be all or nothing so if input 1 is LOW and the rest are HIGH there will be no outputs. I have tried IF function and I cant get it to work can someone please tell me what to do???? I am brand new to Arduino so forgive me if it is something simple.
const int Button1Pin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
const int Button2Pin = 3;
const int Button3Pin = 4;
const int testPin1 = 5
// variables will change:
int buttonState1 = 0; // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 1;
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(Button1Pin, INPUT);
pinMode(Button2Pin, INPUT);
pinMode(Button3Pin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState1 = digitalRead(Button1Pin);
buttonState2 = digitalRead(Button2Pin);
buttonState3 = digitalRead(Button3Pin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if ((buttonState1 == 1) && (buttonState2 == 1));
// turn LED on:
digitalWrite(testPin1, HIGH);
if ((testPin1 == 1) && (buttonState3 == 0));
digitalWrite(ledPin, HIGH);
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}