Design of colored lights based on single chip microcomputer

Publisher:zhuanshiLatest update time:2012-12-28 Source: 电子发烧友 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Introduction

As people need colored lights for house decoration, colored neon lights can be seen in many cities. LED colored lights have been widely used due to their rich light colors, low cost and simple control. It has become a fashion to use colored lights to decorate streets and urban buildings. However, most of the various LED colored light controllers on the market are implemented with full hardware circuits, which have the disadvantages of complex circuit structure, complex circuit, large power loss, etc. In addition, from the perspective of functional effects, there are few lighting modes and the style is monotonous, which lacks user operability.

The global warming crisis and energy shortage are further promoting the popularization of LED lighting. LED lighting is environmentally friendly, has high light efficiency and long life, but in completely replacing incandescent lamps with wall-mounted dimmers, LED lighting still has the inherent disadvantage of poor compatibility. The main reasons are:

1) Existing dimmers are designed for incandescent lamps, which are purely resistive. As a solid-state semiconductor lighting device, LED requires a constant DC current drive, so LED lighting generally requires a driver to convert from AC 110V/220V to the required DC current.

2) There are many types of dimmers, and their working principles are different, including front-cut type, rear-cut type and intelligent type;

3) There are many types of LED lighting. As a result, different types of dimmers are matched to different LED lighting; LED drivers face huge challenges; among them, reliability and safety are particularly important. Lighting is a consumer electronic product that directly contacts consumers in thousands of households. Not only should the price be appropriate, but more importantly, it should be safe and reliable; even if any component fails or the dimmer does not match the LED, it cannot cause any safety failures such as leakage, overheating, overcurrent, etc.

2. Hardware Design

The single-chip microcomputer controls three groups of small lights to light up in sequence according to the single color. It can also control the output voltage by changing the duty cycle of the output pulse to control the lighting of the color LED, realizing the multi-color LED gradient lighting function, so that the three-color lights can emit multiple colors. The single-chip microcomputer controls a certain pin of the P1 port to output high and low levels according to regulations. When the high level is output, the ULN2003 outputs a low level, which is reversed to a high level by the ULN2003, so that the driving transistor is cut off and the LED cannot be lit. The three small lights of each color are controlled by a pin of the P1 port of the single-chip microcomputer chip to realize their sequential lighting and color gradient and color mutation functions.

Figure 1 LED dimming principle block diagram

Figure 2 LED light emitting element circuit diagram

3. Software Design

Figure 3 MCU control LED dimming circuit flow chart

4. Programming

#include

sbit LED1=P1^0;

sbit LED=P1^1;

sbit LED2=P1^2;

unsigned char CYCLE;

unsigned char PWM_ON;

void delay (unsigned int cnt)

{

while(--cnt);

}

main()

{ bit flag;

TMOD=0x01;

TH0 = (65536-100)/256;

TL0 = (65536-100)%256;

IE=0x82;

TR0=1;

CYCLE=50;

while(!flag)

{ delay(20000);

PWM_ON++;

if (PWM_ON == CYCLE)

{ flag=1;

}

}

while(flag)

{ delay(20000);

PWM_ON--;

if (PWM_ON == 0)

{ flag=0;

}

}

}

void time (void) interrupt 1

{ STatic unsigned char count;

TH0 = (65536-100)/256;

TL0 = (65536-100)%256;

if (count == PWM_ON)

{ LED1=1;

LED=1;

LED2=1;

}

count++;

if (count == CYCLE)

{ count=0;

if (PWM_ON!=0)

LED1=0;

LED = 0;

LED2=0;

}}

*

Reference address:Design of colored lights based on single chip microcomputer

Previous article:Dedicated LED lighting driver using digital power control technology
Next article:Single-stage flyback power supply design for LED lighting applications

Latest Power Management Articles
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号