[51 Microcontroller Learning note three]----relays

Source: Internet
Author: User

Relay is an electrical control device, it is when the input (such as voltage, current, temperature, etc.) to reach the specified value , so that the controlled amount of a step change of an electrical apparatus.

For example: we only need to use a 12v,0.1a number to control a relay, and then let the relay to act as a millions of volt, millions of amp device switch.

Relays can be used wherever possible, if you want to keep the controller in a safe environment. Let's go to the safe side and let the relays go to the dangerous side, as long as we control the action of the relays, the relays will help us connect some of the lines that we don't want to touch personally.

The classification of relays is thousands, here is not much to say.

Recently because there seems to be no place to use, here first give the most basic through the key to control the relay switch program source code, later if there are other uses, then again.

1 /****************************2 Experiment name: Key control relay3 experimental time: 2014/12/204 Experimental connection: relay connected to the chip p1^4 end, K1 button to connect the p0^0 end of the chip5 *****************************/6#include <reg51.h>7 8Sbit relay = p1^4;//define the IO port used by the relay9Sbit key = p0^0;//define the IO port used by the keyTen  One voidMain () A { -      while(1) -     { the     //according to the independent key principle, there is a high level when there is no key pressed, low when the key is pressed down -         if(Key = =1)    -relay =1;//The key is not pressed and the relay is disconnected. -         Else +relay =0;//Press the key and the relay is closed -     } +}

Experimental results: When the button is pressed, the relay is closed, the DK Light is on, and the DK lamp is not lit.

[51 Microcontroller Learning note three]----relays

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.