|
|||||||||||||||||||||||
n my inaugural article on how to integrate your .NET applications with external devices, I showed how to display system information using an LCD display. In this article, I will dive into the world of sensors. Sensors are interesting devices because they are the "eyes and ears" of your computer and can provide detailed information about the surroundings, such as temperature, lighting detection, proximity measurement, and so on.
For this article, I will be using two types of sensors: a passive infrared (PIR) sensor and an ultrasonic sensor. The PIR Sensor from Parallax (see Figure 1) is a low-cost sensor ($7.95) that is able to detect motion by using the principle of infrared radiation. It can detect motion up to a range of 20 feet. Its connection is a simple three-pin connectorGND, 5VDC, and a signal line. When motion is detected, the signal line will register a 1, and will fall to 0 when the motion stops. It is ideal for detecting movements. The second sensor, the PING))) Ultrasonic Sensor (see Figure 2), is much more interesting and it is able to provide precise measurement of distance ranging from 2 cm to 3 meters. It works by emitting a short ultrasonic burst and then measures the time it takes the burst to bounce back when it hits an object. By timing this process, it is able to calculate the exact distance between the sensor and the object. The PING))) sensor costs $24.95. Like the PIR sensor, the PING))) sensor has a three-pin connector'GND, 5VDC, and a signal line. The signal line will return the distance measured in pulses (more about pulses later in the article).
Unlike the LCD module that I discussed in my last article, the two sensors in this article cannot be directly connected to the RS-232 serial port of the PC. PC serial ports works on RS-232 voltages and serial communication, while the PIR and PING))) sensors run at 5V (TTL) and uses Pulse-Trigger and Pulse-Width to trigger. Hence, you need a microcontroller to connect to these two sensors; the microcontroller can return the results back to the PC via a serial connection. For this purpose, I used the BASIC Stamp 2 (BS2) Module , also from Parallax. The BS2 is a microcontroller that runs at 20MHz and can execute approximately 4000 instructions per second. The BS2 costs $49. You also need a board to house the BS2 module. I used Parallax's USB Board of Education (BoE) Development Board ($65;see Figure 3).
Connecting the Sensors
There are two ways of connecting the sensors to the BoE board. For the PIR sensor, I will use an LCD extension cable to connect one end of the cable to the PIR sensor and the other end to the servo port. Align the connector to the color coding shown on the board (see Figure 5) and connect it to servo port number 14 (you can connect to any of the other three if you choose; but I will use port 14).
|
|||||||||||||||||||||||
|