Use C language to light up an LED light on the at89c51 microcontroller

Updated on technology 2024-03-21
6 answers
  1. Anonymous users2024-02-07

    With c, I think about it:

    1. It has something to do with hardware, do you know this?

    2. Suppose the LED is connected to the P1 port. The first light is connected. The cathode is connected to IO, and the anode is connected to 5V.

    #include

    bitsecflag;

    unsigned

    charms;

    voiddisplay(unsigned

    charnum,unsigned

    charsec)

    num%=8;

    p1=~(1<

    8;tl0=-50000;

    ms++;IF(ms>20) 12MHz, 50ms timing interrupt, 1 second timing.

    It's easy to expand any of the flashing lights you want.

    display(2,1);

    display(1,1);

    display(3,2);

    display(1,2);

    Just put it in while. Have fun.

  2. Anonymous users2024-02-06

    The assembler takes the AT89C51 microcontroller as the core to design the lantern controller, and the 8-way lantern connected to the P1 port is lit up in the way shown in the figure below.

  3. Anonymous users2024-02-05

    89c51.The P2 port controls 8 LED lights, which are cyclically shifted to the right during normal operation, and 8 LED lights flash when interrupting (INT1).

    Hello dear, glad to answer for you: 89c51The P2 port controls 8 LED lights, and the cycle shifts right during normal operation, and when interrupted (INT1), the 8 LED lights flash as follows:

    The positive stage of the 8 LED lamps is connected to the top of the finger shed, and the negative pole is connected to the top respectively, P1 = 0xff; (P1 port all high) P2 = 0x00; (P2 port is all low), at this time, the current flows through P1 port through the LED to P2 port, all 8 lights are lit, if P1 remains unchanged, P2 = 0xff; At this time, because the interfaces of P1 and P2 are all high, there is no voltage difference and no current, and the LEDs are all off, if you want a certain light to be lit, you can follow the 8421 rule, is the high 8 bits, is the low 8 bits 8 4 2 1 8 4 4 2 1 When P1 = 0xff; p2 = 0xfe, that is, the small light is on, the other 7 are off, p2 = 0xfe this f is 8 + 4 + 2 + 1 = 15, corresponding to the f in the hexadecimal system, the same way e = 8 + 4 + 2 + 0 = 14, spike pulse corresponds to the e in the hexadecimal system.

  4. Anonymous users2024-02-04

    I can send it to you if you want. I have written it in C. With a countdown timer, and the time can be set through the serial port.

  5. Anonymous users2024-02-03

    It looks like the homework assigned by the teacher.

  6. Anonymous users2024-02-02

    It's so simple, you don't always ask you about your homework, I remember that there is a saying in the back door of our university, the market economy doesn't believe in tears.

Related questions
5 answers2024-03-21

8086 belongs to the micro process unit (MPU) and is a microprocessor. >>>More

9 answers2024-03-21

The method of using two timers is to use the timer t0 to control the frequency and the timer t1 to control the duty cycle. The general programming idea is as follows: the t0 timer interrupt makes an i0 port output high, and starts the timer t1 in the interrupt of the timer t0, and this t1 makes the io port output low, so that changing the initial value of timer t0 can change the frequency, and changing the initial value of timer t1 can change the duty cycle. >>>More

12 answers2024-03-21

If the timer count value is not enough, you can first set the sum number of 1, such as 1ms, and then add another number to 10 to 100ms to get the 1s time.

16 answers2024-03-21

Scheduled interrupts, external interrupts?

4 answers2024-03-21

The introductory course of MCU C language programming is not difficult, it is not easy to say, and the first thing to understand is to understand what these two things are when learning MCU C language? The introductory programming of single-chip microcomputer is mainly to learn C language, followed by circuit and programming language. >>>More