Re-pick the first day of single-chip LED lights

Source: Internet
Author: User

The graph knows low-level light, high-level off

Control the first LED1 light out program code, as follows

1#include <reg52.h>2 #defineUchar8 unsigned char3 #defineuint16 unsigned int4Sbit led1=p1^0;5 /*****************************/6 //function Name: delayms ()7 //function function: Delay8 //entry function: Delay millisecond9 //export function: NoneTen /********* *******************/ One voiddelayms (uint16 val) A { - uint16 i,j; -         for(i=0; i<val;i++) the             for(j=0;j<113; j + +); -  - } -  + voidMain () - { +  A     while(1) at    { -led1=0; -Delayms ( +); -led1=1; -Delayms ( +); -       in    } -  to}

——————————————————————————————————————————————————————————————————————————————————————————————————————————————— —————————

Running Light Program code:

1#include <reg52.h>2#include <intrins.h>3 #defineUchar8 unsigned char4 #defineuint16 unsigned int5 #defineLED P16 /*****************************/7 //function Name: delayms ()8 //function function: Delay9 //entry function: Delay millisecondTen //export function: None One /********* *******************/ A voiddelayms (uint16 val) - { - uint16 i,j; the         for(i=0; i<val;i++) -             for(j=0;j<113; j + +); -  - } +  - voidMain () + { A      at     inti; -  -    while(1) -   { -Led=0xFF;//here the port is all set to 1111 1111, which is equivalent to the total loss -     in     for(i=0;i<8; i++) -    { to        +led=led<<1;//left-shift loop selected -Delayms ( +); the        *    } $ Panax Notoginseng   } -  the}

P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0
1 1 1 1 1 1 1 0
1 1 1 1 1 1 0 0
1 1 1 1 1 0 0 0
1 1 1 1 0 0 0 0
1 1 1 0 0 0 0 0
1 1 0 0 0 0 0 0

1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

Experiment Board Phenomenon:

Light on number 1th

1, 2 bright

1, 2, 3 bright

1, 2, 3, 4 bright

。。。。。。

1, 2, 3 ..... 8 All Bright

——————————————————————————————————————————————————————————————————————————————————————————————

Marquee Program code:

1#include <reg52.h>2#include <intrins.h>3 #defineUchar8 unsigned char4 #defineuint16 unsigned int5 #defineLED P16 /*****************************/7 //function Name: delayms ()8 //function function: Delay9 //entry function: Delay millisecondTen //export function: None One /********* *******************/ A voiddelayms (uint16 val) - { - uint16 i,j; the         for(i=0; i<val;i++) -             for(j=0;j<113; j + +); -  - } +  - voidMain () + { A      atLED =0xFE; -  -    while(1) -   { -Led=_crol_ (LED,1);  -Delayms ( +); in  -   } to  +}

Only one LED light is lit.

Re-pick the first day of single-chip LED lights

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.