WOSEN LIGHTING TECHNOLOGY LIMITED

WOSEN LIGHTING TECHNOLOGY LIMITED

Home> Blog> Use the single-chip button to start and stop the led light program programming tutorial

Use the single-chip button to start and stop the led light program programming tutorial

February 27, 2023

MCU button start and stop led light program

#include

Void Delay(unsigned int t); sbit key=P3^2; // corresponding to the s19 button on the microcontroller development board

Void main (void)

{

While (1) / / after the function starts, it is always detecting whether the button is pressed

{

If(key==0) {

Unsigned char i; //Define an unsigned char type local variable i from 0 to 255

P0 = 0x7f; / / assign the initial value, the first light on the right lights up

For(i=0;i<8;i++) //Add a for loop, indicating that the program loop in the for loop is executed 8 times.

{

Delay (50000);

P0>>=1; // Move one bit to the right.

P0=P0|0x80; //After shifting right, the left end is automatically assigned 0, so the statement needs to be assigned 1

}

}

Else

{

P0=0x00;

}

} }

Void Delay(unsigned int t)

{

While(--t);

}

Contact Us

Author:

Ms. Mandy

Phone/WhatsApp:

+8613425434349

Popular Products
You may also like
Related Information
LEAD sincerely released the LED high bay light famous for

On April 22, network activity named "FAST 2015 -! OPEN DAY" was launched by a brand LED high-power outdoor lighting manufacturer- Shenzhen Lead Optoelectronics Technology Co., Ltd.(Chinese name is...

Hublot watch brand ambassadors worldwide "Lightning" Bolt light the light of hope The new Kyoto store interpretation of the fusion of culture

Recently, the world's leading watch brand Hublot and brand ambassador, legendary track and field athlete Usain Bolt hand in hand into Kyoto, the ancient capital of Japan, with passion to ignite...

Cree Introduces XLamp MK-R LED Light Efficiency up to 200lm/W

After two years of breakthrough in the laboratory's light efficiency of 200 lm/W, Cree has finally produced the series of LED chips with 200 lumens per watt at the end of 2012, and officially...

Related Categories

Email to this supplier

Subject:
Email:
Message:

Your message must be betwwen 20-8000 characters

  • Send Inquiry

Copyright © 2024 WOSEN LIGHTING TECHNOLOGY LIMITED All rights reserved. Privacy Policy

We will contact you immediately

Fill in more information so that we can get in touch with you faster

Privacy statement: Your privacy is very important to Us. Our company promises not to disclose your personal information to any external company with out your explicit permission.

Send