The first line of the famous song Twinkle Twinkle Little Star is 1 1 5 5 6 6 5, 4 4 3 3 2 2 1
Then we use the light-emitting diode D1 to replace 1, and so on.
#include "reg52.h"
typedef unsigned char u8;
typedef unsigned int u16;
sbit ledD1=P2^0; //P20
sbit ledD2=P2^1;
sbit ledD3=P2^2;
sbit ledD4=P2^3;
sbit ledD5=P2^4;
sbit ledD6=P2^5;
sbit ledD7=P2^6;
sbit ledD8=P2^7; //P27
void delay(u16 i) //delay function
{
while(i--)
{
//Do nothing
};
}
void main()
{
while(1)
{
//The first sentence of Twinkle Twinkle Little Star is 1 1 5 5 6 6 5 4 4 3 3 2 2 1
//Use the first light to represent 1, and so on
//1
ledD1=0;
delay(60000);
ledD1=1;
delay(60000);
//1
ledD1=0;
delay(60000);
ledD1=1;
delay(60000);
//5
ledD5=0;
delay(60000);
ledD5=1;
delay(60000);
//5
ledD5=0;
delay(60000);
ledD5=1;
delay(60000);
//6
ledD6=0;
delay(60000);
ledD6=1;
delay(60000);
//6
ledD6=0;
delay(60000);
ledD6=1;
delay(60000);
//5
ledD5=0;
delay(60000);
ledD5=1;
delay(60000);
delay(60000);
delay(60000);
//4
ledD4=0;
delay(60000);
ledD4=1;
delay(60000);
//4
ledD4=0;
delay(60000);
ledD4=1;
delay(60000);
//3
ledD3=0;
delay(60000);
ledD3=1;
delay(60000);
//3
ledD3=0;
delay(60000);
ledD3=1;
delay(60000);
//2
ledD2=0;
delay(60000);
ledD2=1;
delay(60000);
//2
ledD2=0;
delay(60000);
ledD2=1;
delay(60000);
//1
ledD1=0;
delay(60000);
ledD1=1;
delay(60000);
delay(60000);
delay(60000);
}
}
Previous article:What is the difference between LED flashing code with loop and without loop
Next article:Basic knowledge of LED and LED in STC89C52
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- Beetle ESP32-C3 test (Part 1) Unboxing and filling holes
- How to connect the power cord and ground wire when charging a lithium battery using a USB-TYPE-C interface?
- Qorvo Launches Complete V2X Front-End Solution
- How to limit the voltage of linear motor drive circuit to 1V
- Are the transistors MMBT2222A and 8050D completely interchangeable? In what applications can they not be replaced?
- Showing goods + embedded primary development board
- Domestic FPGA AGM
- What is the physical meaning of Stokes' formula in advanced mathematics?
- TI|Pain Point Unlocker: We understand your power supply design pain points! Unlock and comment to win gifts!
- Please help me see what went wrong