Ian Cumming
Published © GPL3+

Arduino Simple "Camera Slider" Electronics

The electronics for a simple camera slider, keeping it simple so it can be used with an ATTiny85.

BeginnerFull instructions provided1.5 hours14,356
Arduino Simple "Camera Slider" Electronics

Things used in this project

Hardware components

Stepper Motor 28byj-48
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×4
LED (generic)
LED (generic)
×4
Resistor 221 ohm
Resistor 221 ohm
×4
Resistor 10k ohm
Resistor 10k ohm
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematics

The schematics of the Circuit for driving a stepper motor from an Arduino

Breadboard

The breadboard of a circuit to drive a unipolar stepper motor from an Arduino

Code

TinyStepper

Arduino
ArduinoISP code for the Arduino.
int directionPin = 4;
int motorPins[4] = {0,1,2,3};
byte motorSequence[8] = {B1000,B1100,B0100,B0110,B0010,B0011,B0001,B1001}; 
int motorDirection = 0;
int motorSpeed = 2; // Lower is faster.
//byte motorSequence[8] = {B0111,B0011,B1011,B1001,B1101,B1100,B1110,B0110}; 
//byte motorSequence[8] = {B1000,B0100,B0010,B0001,B1000,B0100,B0010,B0001};
 
void stepMotor(byte motorDirection,int stepSpeed) {
  int readStep = 0;
  int readBit = 0;
  int HIGHLOW = 0;
  for (readStep =0;readStep<8;readStep++) {
    for (readBit=0;readBit<4;readBit++) {
      HIGHLOW = bitRead(motorSequence[readStep],readBit);
      digitalWrite(motorPins[abs((motorDirection*3)-readBit)], HIGHLOW);
    }
    delay(stepSpeed);
  }
}

void stopMotor() {
  int readBit = 0;
  for (readBit=0;readBit<4;readBit++) {
    digitalWrite(motorPins[readBit], LOW);
  }
}


void setup() {
  pinMode(motorPins[0],OUTPUT);
  pinMode(motorPins[1],OUTPUT);
  pinMode(motorPins[2],OUTPUT);
  pinMode(motorPins[3],OUTPUT);
  pinMode(directionPin,INPUT);
}

int pressed = 1;

void loop() {
  while (digitalRead(directionPin) == 1) {
    pressed = 1;
    stepMotor(abs(motorDirection-1),motorSpeed);
  }
  if (pressed == 1) {
      stopMotor();
      motorDirection = abs(motorDirection-1);
      pressed = 0;
  } else {
    stepMotor(motorDirection,motorSpeed);
  }
}

Credits

Ian Cumming

Ian Cumming

6 projects • 71 followers
I like stuff, from building rockets to elctronics.

Comments