Apress - Smart Home Automation with Linux (2010)- P18

Apress - Smart Home Automation with Linux (2010)- P18:Linux users can now control their homes remotely! Are you a Linux user who has ever wanted to turn on the lights in your house, or open and close the curtains, while away on holiday? Want to be able to play the same music in every room, controlled from your laptop or mobile phone? Do you want to do these things without an expensive off-the-shelf kit | CHAPTER 2 APPLIANCE HACKING In addition to light you can also measure temperature thermistors distances ultrasonic range finders and rotary positions by attaching a handle or wheel to the spindle of a potentiometer . Sending Digital Outputs This is as simple as it sounds and includes those cases where you want to send nothing more than a simple on off to something like a light switch or small motor. The code requires a simple setup and invocation like this int outputLightPin 2 pinMode outputLightPin OUTPUT digitalWrite outputLightPin bState TRUE FALSE From here it s all about the circuit. Each pin on the Arduino is able to source current up to around 40 milliamps. This is enough for most small loads such as lights buffers and some small motors. If your device uses no more than 300 milliamps then you can draw this from the circuit board itself using the Arduino as a switch only with a circuit like that in Figure 2-5. ve Load Output Pin 2 Figure 2-5. A transistor switch circuit allowing you to draw up to 300mA For anything larger you will need to employ a relay and separate power source as shown in Figure 2-6. 68 CHAPTER 2 APPLIANCE HACKING Figure 2-6. Using a relay to control high power loads Note In reality the Arduino is good for higher power loads up to 800mA. But for dirty loads such as motors the 300mA is probably more conservatively sensible. Sending Analog Outputs As mentioned previously analog output is available on the basic Arduino only when using PWM. This is supported only on pins 3 5 6 9 10 11 and The pulsing of the output pin to provide the output is handled automatically including the setup so you need only to write this analogWrite analogWritePin value value is between 0 and 255 inclusive This will allow you to vary the brightness of LEDs and the volume of piezo-buzzers and speakers but not a lot else. In reality you won t need a lot else in home automation environs. Moving a motor to a specific position for example is better done with servo or

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
10    72    2    14-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.