File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: Copyright (c) 2025 Liz Clark for Adafruit Industries
2+ #
3+ # SPDX-License-Identifier: MIT
4+
5+ """
6+ Planetary Gear Dreidel Code - slightly modified from the STSPIN220 example
7+ """
8+
9+ import board
10+
11+ import adafruit_stspin
12+
13+ STEPS_PER_REVOLUTION = 200
14+
15+ DIR_PIN = board .D2 # DIRection pin
16+ STEP_PIN = board .D3 # STEP pin
17+ MODE1_PIN = board .D4 # Mode 1 pin (REQUIRED for mode switching)
18+ MODE2_PIN = board .D5 # Mode 2 pin (REQUIRED for mode switching)
19+ EN_FAULT_PIN = board .D6 # Enable/Fault pin (optional)
20+ STBY_RESET_PIN = board .D7 # Standby/Reset pin (REQUIRED for mode switching)
21+
22+ print ("Initializing STSPIN220..." )
23+ motor = adafruit_stspin .STSPIN (
24+ STEP_PIN ,
25+ DIR_PIN ,
26+ STEPS_PER_REVOLUTION ,
27+ mode1_pin = MODE1_PIN ,
28+ mode2_pin = MODE2_PIN ,
29+ en_fault_pin = EN_FAULT_PIN ,
30+ stby_reset_pin = STBY_RESET_PIN ,
31+ )
32+
33+ # Set the speed to 60 RPM
34+ motor .speed = 60
35+ motor .step_mode = adafruit_stspin .Modes .STEP_1_128
36+
37+ while True :
38+ # continuously step the motor
39+ total_microsteps = STEPS_PER_REVOLUTION * motor .microsteps_per_step
40+ motor .step (total_microsteps )
You can’t perform that action at this time.
0 commit comments