Question:
How does a motion sensor turn on a light or open a door perform an action) when triggered?
2015-06-12 11:00:46 UTC
My real question is how a program goes from digital to create an action from a physical device... I'm terrible at explaining my question, I know.

Like, how does the program communicate with the chip?

For instance, someone wrote a program for a smoke detector and depending on conditions determines if it goes off or not. If there is smoke, how does the chip or whatever, communicate and know to execute?
Five answers:
?
2015-06-13 22:33:45 UTC
The motion sensor can open a door or turn on the light without a digital computer of any kind, using analog amplifiers and mechanical relays that switch on a light or activate a gear motor to open the door. Using a micro controller is just easier and cheaper to accomplish the same thing. The motion sensor or PIR device costs about $1.00 on ebay. Inside the PIR is a 1/4" dia. can with of 2 long wave infrared (heat) elements. Light from a special plastic lens focuses IR light on the 2 sensors, and a circuit compares the voltage differences produced, indicating motion (difference in heat occurred between the 2 elements). A circuit then outputs an motion detect signal (5 volts) or no motion signal (0 volts).



The micro controller has digital input pins, which continuously reads the value of the pin, and programming determines what action it will produce. If it turns on a light, a separate digital output pin can be turned on, and that voltage could activate a solid state relay to allow current to flow to the lamp for a length of time as set in the code. If opening a door, several output pins might be used to control the direction of current through the dc gear motor by using an H bridge, thus opening the door on motion sensing, and closing the door afterward. Additional safety devices can be input to the micro controller to prevent closing the door if someone is still standing in the doorway. You can buy the Arduino micro controller for $2.50 to $5.00, and program one yourself.
2015-06-12 12:21:36 UTC
Your question is kind of broad. Usually, in embedded devices, the software and hardware work in tandem. Smoke detectors might not be the best example, because most smoke detectors tend to be purely electronic, with little to no software involved. Same thing with motion detector lights - there's little to no software involved, and functionality tends to be electronic; no "programs" would be written for them, because their behavior is not determined by software.



Now, if you're talking about actual embedded systems devices, like how a smart phone's accelerometer detects tilts and such, that's a different story. The basic idea is that the accelerometer works as a sensor which measures how much of a tilt the device is currently undergoing, and then it might store that data in a memory buffer. The phone's processor is then able to fetch that data and use it to do things (e.g. rotate the phone's screen horizontally, or move a character in a game).



The same thing applies for converting digital commands to physical actions. If the code requires that, say, a motor start turning, usually the interface to the motor will contain some kind of API call for that functionality.
Daniel B
2015-06-12 12:23:46 UTC
For a microprocessor to sense and control the outside world there needs to be some sort interface hardware. So in your smoke detector example there may be hardware that senses smoke and outputs a number between 0 and 255 based on how much smoke is being detected. The software would then continuously read this number and when it reaches a certain value it could write out a value to another piece of hardware that turns on an alarm, or performs some other action.
Nuff Sed
2015-06-17 19:24:55 UTC
Motion sensors are rarely if ever computerized. They simply detect motion electronically (usually with "analog devices", not digital) and trigger an output signal.
tyler
2015-06-12 11:14:08 UTC
with java classes and functiions


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...