Light and Motion Timer

johno43trains

New Member
I am trying to set up a light and motion detector to be timed out, using D06 for PIR input and D07 as PHOTOELECTRIC INPUT.
OUTPUT pin D13. The unit is an Arduino Uno.
Attached is my sketch.Can someone tell me where are I going wrong?
Thankyou.

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 (15000);
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
 
Top