For some reason the wiring wasn't working for the Pi directly connected to the DRV8825. I did have a CNC Shield v3 on hand (also why I had four DRV8825s in the first place) so this is a sketch to control the stepper motor via USB serial.
The pins.h file is set up for a motor and limit switch to be connected to the X axis. The limit switch pins on the shield are wired to the same Arduino pin so +X or -X doesn't make a difference.
An LED can be connected to the Z limit pins via a MOSFET. This pin was chosen for PWM to enable adjusting the brightness. I had a N Channel STP120NF10 on hand, so I connected Gate (Pin 1) to Z Limit, Source (Pin 3) to GND, and Drain (Pin 2) to the LED's cathode (negative). The LED's anode (positive) is connected to +12V (the same driving my stepper motor). Adafruit has a good usage example.
Text, each command is \n terminated
S\nStop: stops the motor and turns off the power to it.MOTORS_DISABLED\nwill be received when the motors stop.
I\n: Information, multiple lines logging the parameters and values will be received:# current speed: 0.00\nshows the (micro)steps per second velocity the motor is told to be moving at# moving speed: 3200.00\nshows the velocity that will be used for an Advance# maximum speed: 10000.00\nshows what the moving speed will be capped at# switch pressed: no\nshows the measured value of the limit switch (yesfor on andnofor off)
AF\n: Advance Frame, will spin the stepper motor CCW until the limit switch is triggered.ADVANCE_FRAME_STARTED\nwill be received when the motor starts turningMOTION_STOPPED\nwill be received when the limit switch is triggeredMOTORS_DISABLED\nwill be received if no Advance command is transmitted within a certain time after the limit switch is triggered.
A\n: Advance, will spin the stepper motor CCW ignoring the limit switchADVANCE_STARTED\nwill be received when the motor starts turning
RF\n: Reverse Frame, same as Advance Frame but CWR\n: Reverse, same as Advance but CWA S 3200\n: Sets the (micro)steps per second velocity of the motor for Advancements# ERR: invalid number\nis received if the value transmitted is determined to not be a number- no messages are received if the value is used, though the Information command can confirm the new value
L A\n: Lamp Activate, turn the lamp/LEDLAMP_ON\nis received after the PWM signal is applied
L D\n: Lamp LAMP_DEACTIVATE, turn the lamp/LEDLAMP_OFF\nis received after the PWM signal is removed (that is, no pulse is applied)
L S\n: Set the lamp brightness, also turning on the lamp if not 0# ERR: invalid number\nis received if the value transmitted is determined to not be a number- no messages are received if the value is out of bounds
LAMP_ON\norLAMP_OFF\nare received if the value is used (0 is seen as off)