johno43trains
New Member
I am wanting to monitor two digital inputs(D06,D07) on a Arduino Uno to provide an output on D13.
This is my code I have written but it seems is only looking at one input. Can someone help me?
// This sketch is written to provide a high to
// D13 by signals from D06 HIGH and D07 HIGH
const int ledPin = 13; // the number of the led pin
const int pirPin = 6; // the number of the pir pin
const int buttonPin = 7; // the number of the photo pin
int buttonState = 0; //variable for reading pushbutton state
int pirState = 0; //variable for pirstate
void setup () {
//initilize the led pin as an output
pinMode (ledPin, OUTPUT);
//initilize the pushbutton pin as photo input pin
pinMode (buttonPin,INPUT);
//initilize the pushbutton as pir input pin
pinMode (buttonPin, INPUT);
// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
}
void loop(){
//read the state of the pushbutton value
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
delay (30000);
// turn LED off:
digitalWrite(ledPin, LOW);
}
This is my code I have written but it seems is only looking at one input. Can someone help me?
// This sketch is written to provide a high to
// D13 by signals from D06 HIGH and D07 HIGH
const int ledPin = 13; // the number of the led pin
const int pirPin = 6; // the number of the pir pin
const int buttonPin = 7; // the number of the photo pin
int buttonState = 0; //variable for reading pushbutton state
int pirState = 0; //variable for pirstate
void setup () {
//initilize the led pin as an output
pinMode (ledPin, OUTPUT);
//initilize the pushbutton pin as photo input pin
pinMode (buttonPin,INPUT);
//initilize the pushbutton as pir input pin
pinMode (buttonPin, INPUT);
// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
}
void loop(){
//read the state of the pushbutton value
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
delay (30000);
// turn LED off:
digitalWrite(ledPin, LOW);
}