7983 views|17 replies

85

Posts

0

Resources
The OP

LED light flashing mode [Copy link]

Now I have 8 LEDs, controlled by 8 I/Os of 51 MCU. My boss asked me to flash 200 modes. If I write a function to implement each mode, I need 200 functions. My boss said 200 functions are too big. He wants to use several functions like movable type printing to realize these 200 modes through different combinations. I am so confused. Does anyone have any good way to achieve this? ? ?
This post is from Embedded System

Latest reply

The problem has been solved. void light (UINT pin1, UINT pin2, UINT pin3, UINT pin4, UINT pin5, UINT pin6, UINT pin7, UINT pin8) can be represented directly by the pin number. There is no need to use the pin as a parameter directly, such as P1_6, assigning 6 to pin6  Details Published on 2008-8-20 09:04

88

Posts

0

Resources
2
You can try to write a few complete functions first, and then you will know which ones can be merged or combined. Practice makes perfect.
This post is from Embedded System

68

Posts

0

Resources
3
What the above person said is very correct. Just like image display, we first consider how to display points, then lines, and then surfaces. Then it is a question of combination.
This post is from Embedded System

75

Posts

0

Resources
4
In fact, it is a function: void LED (char num); // num is the number of LEDs 0-7, whichever one you want to light up. As for how to use this function to achieve 200 modes, it depends on the so-called "mode" requirements. 200 modes? No specific instructions? The simplest one is: 2 to the eighth power is 256, which is binary display, adding 1 each time, so it can be satisfied.
This post is from Embedded System

72

Posts

0

Resources
5
Can be implemented with case
This post is from Embedded System

87

Posts

0

Resources
6
It's not a big deal! One function can handle all 255 types. void LED(byte num) {byte i; POTA=num; } num is a byte in binary, representing the output of 8 outputs, 1 is high level, 0 is low level, how to combine it is up to you to think about it! ~~
This post is from Embedded System

73

Posts

0

Resources
7
It would be even more perfect if we can control the duration of each LED lighting: void LED(byte num, byte timeperiod) { }

This post is from Embedded System

86

Posts

0

Resources
8
Therefore, if the demand is not clear, the case cannot be done. If the question is vague, there will be many answers.
This post is from Embedded System

66

Posts

0

Resources
9
The flashing pattern of 8 lights can be 1237 for 3 seconds, 2468 for 3 seconds, or from 1 to 8, or from 8 to 1, and so on. Even if you put 200 flashing patterns into one function, you still have to write 200 patterns in the end.
This post is from Embedded System

77

Posts

0

Resources
10
Only when you have clear requirements can you do things. Since you need 200 kinds of things, and they have nothing in common, you have to write 200 kinds. It is not difficult to do things without rules, but it is annoying.
This post is from Embedded System

66

Posts

0

Resources
11
Quote from Shuiyan on the 7th floor: So, if the demand is not clear, the case cannot be done. If the question is vague, there will be many answers.
This post is from Embedded System

79

Posts

0

Resources
12
There is a pattern! If you light up from 0 to FFH, there are 255 modes. If you add the time variable, it will be infinite.
This post is from Embedded System

78

Posts

0

Resources
13
I think I should end this post.
This post is from Embedded System

76

Posts

0

Resources
14
I think your design should find out the commonalities of these LEDs, and how to simplify your design. Through these commonalities and the optimal parameters, you can control them. Think about it yourself.
This post is from Embedded System

86

Posts

0

Resources
15
It's difficult!
This post is from Embedded System

76

Posts

0

Resources
16
There are 8 functions that have delays, settings, and numbers.
This post is from Embedded System

74

Posts

0

Resources
17
There is also a loop that is put into it one by one
This post is from Embedded System

56

Posts

0

Resources
18
The problem has been solved. void light (UINT pin1, UINT pin2, UINT pin3, UINT pin4, UINT pin5, UINT pin6, UINT pin7, UINT pin8) can be represented directly by the pin number. There is no need to use the pin as a parameter directly, such as P1_6, assigning 6 to pin6
This post is from Embedded System

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

    EEWorld
    subscription
    account

    EEWorld
    service
    account

    Automotive
    development
    circle

    Robot
    development
    community

    Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
    快速回复 返回顶部 Return list