File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 11# MicroPython-NodeMCU
22Command for burn flash
33``` python
4+ boot.py : auto loading code after boot
5+
46deploy : quick command to modify the serial port and baud rate w/ fast speed
57 port = / dev/ tty.SLAB_USBtoUART
68 baud = 921600
@@ -23,4 +25,6 @@ led_breath_timer.py : make LED light and dim
2325 software PWM , Timer
2426 set each period w/ timer
2527
28+ stepper.py : use 28BYJ - 48 5V DC stepper
29+
2630```
Original file line number Diff line number Diff line change 1+ from pyb import Pin
2+ from time import sleep_ms , sleep_us
3+
4+ D1 = Pin (5 , Pin .OUT )
5+ D2 = Pin (4 , Pin .OUT )
6+ D3 = Pin (0 , Pin .OUT )
7+ D4 = Pin (2 , Pin .OUT )
8+
9+ #steps of revolution = 4096, 8*512
10+ seq = [[0 ,0 ,0 ,1 ],
11+ [0 ,0 ,1 ,1 ],
12+ [0 ,0 ,1 ,0 ],
13+ [0 ,1 ,1 ,0 ],
14+ [0 ,1 ,0 ,0 ],
15+ [1 ,1 ,0 ,0 ],
16+ [1 ,0 ,0 ,0 ],
17+ [1 ,0 ,0 ,1 ]]
18+
19+ def rotate (RPM , angle ):
20+ if (RPM > 20 ):
21+ print ("RPM should less than 20" )
22+ return
23+ delay = int (60 * 1000 * 1000 / 4096 / RPM )
24+ steps = int (512 * abs (angle )/ 360 )
25+ if angle < 0 :
26+ direction = - 1
27+ else :
28+ direction = 1
29+ for i in range (steps ):
30+ for step in seq [::direction ]:
31+ set_step (step )
32+ sleep_us (delay )
33+
34+ def set_step (step ):
35+ D1 .value (int (step [0 ]))
36+ D2 .value (int (step [1 ]))
37+ D3 .value (int (step [2 ]))
38+ D4 .value (int (step [3 ]))
39+
40+ for i in range (1 ):
41+ rotate (20 , 360 )
42+
43+ #
You can’t perform that action at this time.
0 commit comments