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

What is the program of 28BYJ-48 stepper motor?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)05/31 Report--

Today, I will introduce to you how to master the program of 28BYJ-48 stepper motor. The editor thinks that the content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.

Below, we have completed the procedure of mastering motor migration and transformation with infix, but in practice, this program still does not have much applicable value, so we can't turn it on and off every time we want it to migrate and change, can we? In addition, it can not only turn forward but also reverse, that is to say, it can not only turn around, but also turn back. All right, let's do an example program, combined with the button program in Chapter 8, we design such a function program: press the number key 1x 9, master the motor turn 1x 9 laps; the joint venture up and down keys change the shift bias, press the up key to turn 1 °9 laps, and the downward key turns 1 °9 laps; the left key is fixed 90 degrees, and the right key is fixed and reversed 90 ESC to terminate the migration transition. Through this procedure, we can also further understand how to use keystrokes to master the complex functions of the program, and how to master and perform the tasks between modules. and your programming level can also be tempered and promoted in such a theoretical exercise.

# include sbit KEY_IN_1 = P 2 ^ 4; sbit KEY_IN_2 = P 2 ^ 5; sbit KEY_IN_3 = P 2 ^ 6; sbit KEY_IN_4 = P 2 ^ 7; sbit KEY_OUT_1 = P 2 ^ 3; sbit KEY_OUT_2 = P 2 ^ 2; sbit KEY_OUT_3 = P 2 ^ 1; sbit KEY_OUT_4 = P 2 ^ 0 Unsigned char code KeyCodeMap [4] [4] = {0x31, 0x32, 0x33, 0x26}, / / numeric key 1, numeric key 2, numeric key 3, up key {0x34, 0x35, 0x36, 0x25}, / / numeric key 4, numeric key 5, numeric key 6, left key {0x37, 0x38, 0x39, 0x28}, / / numeric key 7, numeric key 8, numeric key 9, down key {0x30 0x1B, 0x0D, 0x27} / / number key 0, ESC key, enter key, right Arrow} Unsigned char KeySta [4] [4] = {1, 1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1}}; signed long beats = 0; / / the total number of motor transfer rhythms void KeyDriver (); void main () {EA = 1; / enable total midfix TMOD = 0x01; / / set T0 to form 1 TH0 = 0xFC / / assign initial value 0xFC67 to T0, just in time 1ms TL0 = 0x67; ET0 = 1; / enable T0 suffix TR0 = 1; / / start T0 while (1) {KeyDriver () / / misuse the key drive function}} / * the starting function of the stepper motor, the angle angle- needs to turn * / void StartMotor (signed long angle) {/ / close the infix before calculation, and open it again after completion, to prevent the infix from interrupting the calculation process and form a fault EA = 0; beats = (angle * 4076) / 360; / / the measured value is 4076 beats, and the transition circle EA = 1 } / * stepping motor stop function * / void StopMotor () {EA = 0; beats = 0; EA = 1;} / * press the key action function, according to the key code to perform the response operation, keycode- key code * / void KeyAction (unsigned char keycode) {static bit dirMotor = 0; / / Motor migration transition bias / / master motor migration transformation 1-9 laps if ((keycode > = 0x30) & (keycode)

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

Network Security

Wechat

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

12
Report