Homemade "heart-shaped" microcontroller breathing light

Publisher:平和梦想Latest update time:2017-01-04 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The so-called "breathing light" is to control the flashing process of the LED light through a program, which has a rhythm like breathing and a gradual brightness change process.


First, here is a rendering:

 

 

This picture is a bit big...

 

This is what it looks like without any decoration, but after some simple decoration, it becomes something super cute.

 

 

 

Production process:

 1 //******************************

 2 // 51 MCU simulates breathing light

 3 // 2012.9.23

 4 // menglei

 5 // p0.0 is connected to an LED light, state 0 is on

 6 //******************************

 7 

 8 

 9 #include

10 #define N 2 //Brightness and darkness rate

11 #define T 800 //PWM period

12 #define T1 1400

13 #define T2 900

14 //sbit led0=P0^0;

15 //======================

16 void pwm(int x)

17 {

18 while(x--);

19 }

20 //======================

twenty one 

22 void flash1(void){

23 int t = 0;

24 char f = 0;

25 int count = 5; //5 times, the number of times each function is executed

26 while(1){

27 P0 = 0x00;

28 pwm(t); //Toff, light time

29 //led0=1;

30 P0 = 0xff;

31 pwm(T-t+100); //Ton, dark time

32 if(!f) t+=N+1; //The light rate is fast, simulating breathing

33 else t-=N; // dark rate is slower

34 if(t>T) {f=1;t=T;} //When the maximum value is exceeded, the maximum value is returned and the flag is dark.

35 if(t<0) {f=0;t=0;}//When the minimum value is exceeded, the minimum value is returned and the flag is lit

36 // count--;

37 }

38 }

39 void main()

40 {

41  

42 while(1)

43 {

44 flash1();

45 } 

46 }


There are not many programs, but the production of the circuit is indeed very time-consuming and brain-consuming, because you have to consider the routing of each line and can't make the line too complicated

This is the middle part, like a CRT TV, hahahaha

front:

 

The wiring during debugging: (disgusting)

 

 

Final production:


Reference address:Homemade "heart-shaped" microcontroller breathing light

Previous article:The Principle and Implementation of 51 Single Chip Microcomputer Multitasking Operating System
Next article:The role of the header file INTRINS.H in Keil

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号