How to light up a light-emitting diode using a 51 single-chip microcomputer

Publisher:pingbashouLatest update time:2015-01-07 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This is an experiment that everyone who learns 51 single-chip microcomputers will do, and it should be the first experiment. It is so simple and popular that there is nothing much to say, but I thought of some things that can be put together and talked about. First, here are the pictures:


This is the schematic diagram of the LED part on a certain experimental board. When conducting LED experiments, J1 must be connected, otherwise VCC cannot power the LED. RP1 is a resistor array. Our common resistors are all separate, while a resistor array is 8 resistors connected together, and these 8 resistors have a common section. In this figure, the common end is connected to VCC.


Then there is the resistance value of 102. Here it does not mean that the resistance value is only 102 ohms, but 10*102, which is 1000 ohms. The main function of this resistor is to limit the current, so how much current flows through the resistor? Assuming VCC is 5V and the voltage drop of the light-emitting diode is 1.7V, there is a voltage of 3.3V on the resistor. According to Ohm's law, voltage/resistance=current, we get 3.3ma. This is the current flowing through the LED. Don't think that the power consumption is small. Among the commonly used handheld instruments, they are generally powered by four Nanfu batteries. The power consumption of this instrument is required not to exceed 50ma.

Imagine that the CPU + peripheral circuits + several LEDs must be controlled within 50ma.

I have another question. Has anyone noticed that we need an external power supply to light up the LED instead of using the internal power supply of the microcontroller?


There are two reasons: 1. If the microcontroller is used for power supply, the load on the microcontroller is relatively large; 2. After the microcontroller is powered on and reset, the initial level of the pin is high. The above circuit just ensures that the LED is dark. Otherwise, there will be a process of pulling the level down. For patients with obsessive-compulsive disorder, this process is very disgusting. Here is a piece of code:


#include //Include header file

//#include "stc.h"

void main() //void

{

P1=0xfe; //1111 1110B

while(1)

{

}

}

 

Reference address:How to light up a light-emitting diode using a 51 single-chip microcomputer

Previous article:Wireless Bluetooth car based on 51-gesture remote control is awesome
Next article:Radio based on STC89C52RC+TEA5767

Latest Microcontroller 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号