Using 2 sensors advice

Hi All,

I am doing a project where I would like to time how long a light is left on in a room while the room is not being used. I want to use a light sensing sensor to activate the motion sensor when a light is turned on, and when the motion sensor is inactive to start a timer to time the amount of time the room is unused, until either the light is turned on or the motion sensor senses active.

What is the best way to go about this??

Post your sketch to see how we can help.

Many folk would use an LDR for light sensing. This can work OK.
But some LDRs have broad (and sometimes unusual) wavelength sensitivity.
So, for the "sensing light" element, you might like to investigate an ambient light sensor.
I tend to use the TEPT4400. It is sensitive to visible light as seen by the human eye - a peak
sensitivity of around 570nm. Used with a 20k resistor, it gives a good voltage swing into an analogue input.

There are many, low cost, PIR movement sensors available. They will usually give a pulsed signal to the arduino (i.e. switching on for X seconds when there is movement), so you will need to monitor toggles on a digital pin.

are you asking about devices for sensing light?

are you asking how to design the code?

how do you want to report/log this information? simple prints on a screen or SD card?

presumably you want to use an arduino? attached/powered by laptop or standalone?

Apologies, I was very vague in my question. I have a light sensor and PIR movement sensor. I need help with hooking them both up to the Arduino board and then writing the code to do the following:

  • sense when a light is turned on
  • When a light is on start detecting motion within the room
  • time how long the light is on for
  • detect how long the light is on for and the motion sensor is active
  • detect how long the light is on for and the motion sensor is inactive

I can get the sensors to work individually but not together


I need help with the code, and logged on an SD card
Stand alone

Please post your two working codes for the sensors.
Please post your problem code where you edited the codes together?

Please use code tags.
To add code please click this link;

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.