Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the myth of lighting with C#

2025-03-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to use C # to realize the myth of lighting". In the daily operation, I believe that many people have doubts about how to use C# to realize the myth of lighting. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how to use C# to realize the myth of lighting"! Next, please follow the editor to study!

In electronics, there are only concepts such as voltage and current, but for single-chip microprocessors, we can think that 0 represents low voltage (low level, grounding) and 1 represents high voltage (high level). On the STM32 single chip microcomputer we are learning, the high level is actually 3.3V! Today we want to light the small lamp, is the light-emitting diode, let 3.3V and 0V respectively connected to the positive and negative (length) of the light-emitting diode, we can make it emit light!

The single-chip microcomputer we use has many pins (ZET6 is 144pins, VET6 is 100pins), which is generally named PA0~PA15,PB0~PB15. In theory, we can set any foot to high level or low level, through the single-chip microcomputer program.

In that case, there are two kinds of wiring: one is that the diode connects to a pin Pin at one end, the other to the GND pin, and then controls the high level of the Pin, which can be lit; but the two pins are connected to make the positive pin (long) output high level, and the negative pin (short) output low level, which can also be lit.

If you write this control program in C, it will be a little complicated, because you need to set the working mode of the pin, pull up and down and so on, and then you can control the high and low level through 01. Most of our students who do C # development do not understand this. MF is well encapsulated in this respect, instantiating an output port OutputPort for the specified pin, and specifying the initial state true/false, and then you can read and write Boolean values. Of course, this output port can also specify the up-and-down mode, but if we don't understand, we don't need that constructor.

General development boards are equipped with LED, there is no need for us to pick up LED! If you want to do horse racing lanterns or something, you can buy one on Taobao yourself, one for a dime, and you can buy a hundred for 10 yuan, but remember to buy DuPont line, !

Let's look at the code:

/ / Red Bull II / / var pins = new Cpu.Pin [] {Pins.PF6, Pins.PF7, Pins.PF8, Pins.PF9, Pins.PF10}; / / Apollo 1 / / var pins = new Cpu.Pin [] {Pins.PE11, Pins.PE12, Pins.PE13, Pins.PE14, Pins.PE15}; / / Explorer 1 / / var pins = new Cpu.Pin [] {Pins.PB11} / / Explorer 2 / / var pins = new Cpu.Pin [] {Pins.PC6, Pins.PC7}; / / Athena II var pins = new Cpu.Pin [] {Pins.PF8, Pins.PF9}; / / Athena III / / var pins = new Cpu.Pin [] {Pins.PF8, Pins.PF9}; var leds = new OutputPort [pins.Length]; for (int I = 0; I < pins.Length) For +) {leds [I] = new OutputPort (pins [I], I% 2 = = 0);} / / var led4 = new Led4 (); for (int I = 0; I < 20000; iLeads +) {for (int j = 0; j < leds.Length; jacks +) {for [j] .Write (! Leds.Sleep ());} / / led4.Display (I); / / led4.Value = iThread.Sleep (50) At this point, the study on "how to use C# to realize the myth of lighting lights" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report