Single-chip microcomputer IO Port standard bidirectional, push-pull, high resistance, open-drain mode, LED induction light-off experiment "Original!" 】

Source: Internet
Author: User
Tags 0xc0

Single-chip microcomputer IO Port standard bidirectional, push-pull, high resistance, open-drain mode, LED induction light off experiment

11 Long vacation at home rotten, nothing to do, DIY technology get up!


"An experimental study on the working type of the 12C enhanced microcontroller I/O port"

Animation video effect Download: STC single-chip head file "51cto--> single-chip microcomputer-->led induction light-off experiment"

Download link Link: http://pan.baidu.com/s/1pJKK4w7 Password: a0re



1, with strong push mode, lit an LED

/* Project to create MCU selection, Atmel 89c55 microcontroller: STC12C4052AD Crystal: No requirements function: With strong push mode, light up an LED connection description: Led positive string 1K resistor P1 ^ 7, negative to MCU P1 ^ 6 corresponding P1 Port 7654 32 10P1M0 = 0x00; -->0000 0000p1m1 = 0xC0; The-->1100 0000p1^7,p1^6 is set to strong push mode, which provides 20ma pull-up current */#include <stc12c2052ad. H>sbit LED1 = P1 ^ 7;sbit LED2 = P1 ^ 6;void main (void) {p1m0 = 0x00;   P1M1 = 0xC0;    Led1=1; led2=0;}



2, high resistance mode, no output current

/* Project to create MCU selection, Atmel 89c55 microcontroller: STC12C4052AD Crystal: No requirements: High resistance mode, no output current connection description: Led positive string 1K resistor P1 ^ 7, negative to MCU P1 ^ 6 corresponding P1 port 7654 3210P 1M0 = 0xC0; -->1100 0000p1m1 = 0x00; -->0000 0000*/#include <stc12c2052ad. H>sbit LED1 = P1 ^ 7;sbit LED2 = P1 ^ 6;void main (void) {p1m0 = 0xC0;   P1M1 = 0x00;    Led1=1; led2=0;}



3, high resistance mode, LED induction light off

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/03/wKiom1YM54PhpTmeAArB8raNku0170.jpg "title=" sense. png "alt=" Wkiom1ym54phptmeaarb8ranku0170.jpg "/>

/* Project to create MCU selection, Atmel 89c55 microcontroller: STC12C4052AD Crystal: No requirements: High resistance mode, finger distance p3^7 2 mm away, led induction light off, do not need to touch the p3^7 foot connection instructions: Led positive string 1K resistor connected to VCC, the negative received MCU P1 ^ 7 power supply Instructions: The computer's USB interference than the mobile power interference to be larger, the use of computer USB and mobile power supply, the effect of contrast is obvious! */#include <stc12c2052ad. H>sbit LED = p1^7;sbit KEY = p3^7;void Main (void) {p3m0 = 0x80; P3M1 = 0x00;//high-impedance led=1; LED = p1^7; No need to set the status of key, because it will not be output! while (1) {Led=~key;}}








4, high resistance mode, adjust the LED light sensing distance


Put the test diagram first!

Computer USB power supply, test report:

Adjusted to Delay_ms 6 4 without touching, the surrounding interference will trigger the LED light

See!


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/74/00/wKioL1YM6GeQVKAsABNaAXte55s867.gif "title=" Automatic 1.gif "alt=" Wkiol1ym6geqvkasabnaaxte55s867.gif "/>


Adjusted to Delay_ms 7 3 isolated 2 cm LED light

See!


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/03/wKiom1YM6VvDApRPAA6MnL0I1AQ490.gif "title=" 2cm2.gif "alt=" Wkiom1ym6vvdaprpaa6mnl0i1aq490.gif "/>


Adjusted to Delay_ms 8 2 isolated 2 mm LED light

See!

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/00/wKioL1YM6e_hRUNfABlBdvQOYbs349.gif "title=" 2mm1.gif "alt=" Wkiol1ym6e_hrunfablbdvqoybs349.gif "/>






Adjust to Delay_ms 9 1 requires touch pin to light

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/03/wKiom1YM6iiQD3MGABsoOtIfQ1o520.gif "title=" Peng1.gif "alt=" Wkiom1ym6iiqd3mgabsootifq1o520.gif "/>




induction lamp, adjust the LED light sensing distance source code!

/* Project to create MCU selection, Atmel 89c55 microcontroller: STC12C4052AD crystal: No requirement function: High resistance mode, finger distance p3^7 2 mm far, led induction light off, do not need to touch the hand p3^ 7 Foot Connection instructions: Led positive string 1k  resistor connected to VCC, negative to &NBSP;MCU p1 ^ 7 power supply Instructions: The computer's USB interference than the interference of the mobile power supply, the use of computer USB and mobile power supply, the effect of contrast is obvious! */#include  <stc12c2052ad. h>sbit led = p1^7;sbit key = p3^7; void delay_ms  (unsigned  int a)  {    unsigned int i;    while  (  --a != 0 )   {        for  (i=0;i <=600;i++);    }}void main  (void)  {  P1M0 = 0x00; p1m1 = 0x00;  //General   P3M0 = 0x80; p3m1 = 0x00;//High impedance  LED=1;// LED = P1^7;  no need to set key status because it will not be output!   KEY=0;//  always pull low//adjust sensitivity, from two cm to the pin must be touched, LED sensor light while  (1) {P3m0 = 0x00;delay_ms (6) ;   p3m0 = 0x80;  delay_ms (4); Led=~key;}}   Computer USB power supply, test report://  respectively to  DELAY_MS 6 4  do not touch, the surrounding interference on the trigger led bright//  respectively adjusted to  delay_ms  7 3  isolation 2 cm  led bright//  respectively adjusted to  DELAY_MS 8 2  isolation 2 mm  led bright//  respectively adjusted to  DELAY_MS 9 1  requires touch pin to light


"No reprint!" 】




This article comes from "Life is endless, tossing and turning." "blog, declined reprint!"

Single-chip microcomputer IO Port standard bidirectional, push-pull, high resistance, open-drain mode, LED induction light-off experiment "Original!" 】

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.