Thursday, September 17, 2015

Custom Stairway + Hallway Lighting Project - Part 2

I finally got a hold of  the IR sensor on Monday and got it hooked up.  I found that it does tend to fluctuate over time.  I think this is part of its sensing timing based on the datasheet.  To help combat this I change the code to average the last 4 readings.  These readings are most likely going to be about 10ms apart when all is said and done.  So realistically it could take up to 50ms to trip the lights.  That's quick enough for me.


I found a problem with my original designs though when I got the sensor.  What I didn't really think about was that the sensor's output is analog.  This is a problem because there are only 6 analog sensors on the micro-controller and I had already earmarked all of them for the light sensors.  I figured I could ditch 1 of the light sensors in one of the hallways, but that still left me with 1 sensor too many.

Initially I was thinking about moving from the Duo to the Mega.  Lots more inputs, but it's also physically bigger and more expensive.   I was chatting with a friend of mine who suggested looking into a multiplexer.  After doing some reading this definitely was going to solve my input problem.  I found this one which is already all broken out.  Having the information in hand I set about redesigning the circuit with the new information.  I also am pretty sure that I'm going to use the passive IR sensors in the other places instead of the active ones.



On the software side of things I did some work on the classes and such.  I wanted to subclass the sensors to make adding new sensors simpler to do.  Also cleaned up the debug code which will let me turn debugging on and off specific pieces of debug code.  Also moved all of the code and fritzing diagrams into github.  https://github.com/iamwyza/CustomLightingController/

Next on the docket I think is to test the sensors in the hall ways and make sure they are going to function as expected.  Once that is done I can start ordering the actual final hardware.

No comments:

Post a Comment