Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino 101 Controlled Stepper Motor with Button Activation

View and Edit Project In Cirkit DesignerImage of Arduino 101 Controlled Stepper Motor with Button Activation

Circuit Documentation

Summary

This circuit involves an Arduino 101 microcontroller, a stepper motor, a 7.4V power supply, a toggle switch, resistors, and an arcade button. The Arduino 101 controls the stepper motor based on the state of the arcade button. The circuit is powered by a 7.4V power supply, and the toggle switch is used to control the power to the circuit.

Component List

  1. Arduino 101

    • Description: Microcontroller board based on the Intel Curie module.
    • Pins: A5/SCL, A4/SDA, AREF, GND, D13/SCK, D12/MISO, D11 PWM/MOSI, D10 PWM/SS, D9 PWM, D8, D7, D6 PWM, D5 PWM, D4, D3 PWM, D2, D1/TX, D0/RX, AIN, ioref, RESET, 3V3, 5V, VIN, A0, A1, A2, A3, ICSP MISO, ICSP SCK, ICSP MOSI
  2. Stepper Motor

    • Description: Stepper motor with four control pins and power pins.
    • Pins: IN1, IN2, IN3, IN4, +, -
  3. 7.4V Power Supply

    • Description: Power supply providing 7.4V.
    • Pins: +, -
  4. Toggle Switch (SPST)

    • Description: Single-pole single-throw toggle switch.
    • Pins: L1, COM
  5. Resistor (200 Ohms)

    • Description: Resistor with a resistance of 200 Ohms.
    • Pins: pin1, pin2
  6. Arcade Button (Red)

    • Description: Arcade button with a single pin.
    • Pins: no name yet

Wiring Details

Arduino 101

Stepper Motor

7.4V Power Supply

Toggle Switch (SPST)

Resistor (200 Ohms)

Arcade Button (Red)

Code Documentation

#include <Stepper.h>

// Define the number of steps per revolution for your motor
#define STEPS_PER_REV 200

// Initialize the stepper library on the pins connected to the motor
Stepper stepper(STEPS_PER_REV, A5, A4, A3, A2);

// Define the button pin
const int buttonPin = 2;

// Variable to store the button state
int buttonState = 0;

void setup() {
  // Set the speed of the motor in RPM
  stepper.setSpeed(60);

  // Initialize the button pin as an input
  pinMode(buttonPin, INPUT);
}

void loop() {
  // Read the state of the button
  buttonState = digitalRead(buttonPin);

  // Check if the button is pressed
  if (buttonState == HIGH) {
    // Define the number of steps for each interval
    int stepsPerInterval = 50; // Adjust this value as needed

    // Rotate the motor a specific number of steps in one direction
    stepper.step(stepsPerInterval);
    delay(1000); // Wait for a second

    // Rotate the motor a specific number of steps in the opposite direction
    stepper.step(-stepsPerInterval);
    delay(1000); // Wait for a second
  }
}

This code initializes the stepper motor and the arcade button. When the button is pressed, the stepper motor rotates a specific number of steps in one direction, waits for a second, and then rotates the same number of steps in the opposite direction. The speed of the motor is set to 60 RPM.