# Built-in stepper motor sequence generator
Stepper motors move by taking precise steps. This means that the controller can move to a defined
position, and back to the starting position without errors. Motors can have large step sizes (20 steps per revolution), or very small (600/rev)
The kuttypy GUI can generate a full step sequence for controlling 4 wire stepper motors via PB0-PB3 pins.
Since the current driving capability of the ATMEGA32 is somewhat limited, it is
advisable to use a push-pull driver IC such as the L293D with larger motors.

## Procedure
- Launch the window from the menu on the bottom right side of the screen
- Connect 4 wire, 2 phase stepper motor's A+,B+,A-,B- to PB0, PB1, PB2, PB3
- use the left and right arrow buttons to take single steps
- home button to return to original position
- the numeric entry field to move to a different position
## Video of the stepping sequence
LEDs are connected to PB0-PB3 to show the stepping signal outputs
## Applications
- Move a light sensor (TSL2561) along a diffraction pattern, and record the intensity profile
- Rotate the analyzer in a [Malus's law experiment](../malus), and record the intensity variation which corresponds to IoCos^2(Theta)$
# C Code for controlling
We'll be using the 28BYJ-48 stepper motor and its controller. It is unipolar.
B0 to B3 pins will be set as output, and the stepping sequence will be applied to
these pins.

The motor driver

```python
#include
#define DELAY 5
#define STEPS 200
int main (void)
{
DDRB = 15; //For controlling the stepper motor
uint8_t steps[]={0b1100,0b0110,0b0011,0b1001}; // 12,6,3,9
uint16_t pos = 0;
for(;;)
{
for(pos=0;pos