Timer Application---Query mode---Let 8 LED lights, left and right each of 4

Source: Internet
Author: User

The application of the timer, query method. Let 8 LED lights, left and right each of the 4 to light back and forth

Code:

 /********************** Query method is the main program continuous query is interrupted, and do not need to prepare the sub-program ***********************/#include<reg51.h>#defineLED P1#defineCOUNT 50000//50000 * 1us = 0.05s 50000 counts several times#defineTH_M1 (65536-count)%256//MODE 1 is assigned to a high of 4 bits#deefine tl_m2 (65536-count)/ the     //MODE 1 quotient value to lower 4 bitsMain () {inti; Tmod=0x01;//Mode 1 start T0 interruptLed=0xf0;//1111,0000 4 Lights on the right side of the common anode     while(1)    {         for(i=0;i<5; i++)//5 times Interrupt Timer{TH0= TH_M1;//re-assigning initial value after overflowTL0 =th_m1; TR0=1;//Start T0             while(tf0==0)//Time Flag Timing Flag tf==0 Description overflow, waiting for overflowTF0 =0;//clear TF0, close T0} LED=~led;//LED Reverse Phase    }}

Timer Application---Query mode---Let 8 LED lights, left and right each of 4

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.