Light/Motion Monitor

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);
}
 

Buzby

Senior Member
Welcome to the PICAXE forum !.

We do PICAXE here, not those Ardywino things.

When you see the light, and move over to an AXExxx, then we can help.
 

hippy

Ex-Staff (retired)
Welcome to the PICAXE forum.

Unfortunately it is the PICAXE forum and not the place to resolve issues with other microcontrollers. You really need to seek out an Arduino forum for help and assistance.

Or take the plunge with a PICAXE and code for that. There will be plenty of help here if you choose that path.
 

Buzby

Senior Member
I think this is what you are trying to do :

Code:
symbol Buttonpin = pinb.6
symbol PIRpin = pinb.7
symbol LED = c.0

do

	if Buttonpin = 1 or PIRpin = 1 then
	
		high LED
		
		pause 30000
		
		low LED
	
	endif

loop
So much easier with a PICAXE !.
 
Top