Project tutorial
Arduino Simple "Camera Slider" Electronics

Arduino Simple "Camera Slider" Electronics © GPL3+

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

  • 19 respects

Components and supplies

Apps and online services

About this project

Welcome Everyone

Today we're building electronics for a simple slider, without using a stepper driver chip or breakout board.

We will need the following:

  • Some Jumper Wires
  • 1 x 10k Resistor
  • 1 x Button
  • 4 x 220 Ohm Resistors
  • 4 x NPN Transistors (I've used the pn2222)
  • 4 x LED's
  • 1 x 5v Unipolar Stepper Motor (I'm using the 28BYJ-48 Motor)
  • a Breadboard
  • and an Arduino.

Connect the 2 negative rails of the breadboard to the ground pin of the Arduino, then connect the 2 positive rails of the breadboard to the 5v pin of the Arduino.

Lets start off with the button section

Place the button on the breadboard (In the final slider there are 2 contact points that will be closed once the sliding unit reaches either end). Connect one end of the button to the positive rail. Connect the other end of the button to ground using the 10K resistor. Connect pin 3 of the Arduino to the intersecting point of the button and resistor.

Now lets start building the stepper driver circuit

(It's important to note here that the transistors must be able to handle the max current draw of the stepper motor, you can find this info on the datasheets).

Place a transistor on the breadboard

For the pn2222 transistor the first pin is the Emitter, connect the Emitter pin to the ground rail. The collector is the 3rd pin on the pn2222, connect a lead to the Collector of the transistor and let it hang (We will be using this to connect the stepper motor later).

The middle pin is the Base, connect a LED to the Base of the Transistor and another terminal strip. Connect one of the 220 Ohm resistors to the LED and to another terminal strip. Connect a lead between the resistor and the Arduino.

Repeat this process until you have 4 of these "Electronic switches" connected to pins 5, 6, 7 and 8.

Moving on to the connection of the stepper motor

Connect a lead between the positive rail and the positive of the stepper motor. Connect the leads hanging in the breeze to the stepper motor. Ensure to connect the leads using the order found in the datasheet of the stepper motor.

We are all done with the circuit lets head over to the programming explanation. This program runs the stepper motor and decides what to do when the button is pressed.

The program continuously checks to see if the button is pressed. The motor goes in one direction until the button is pressed down then the motor will reverse its direction and keep on going in that direction even when the button is released. If the button is pressed again it will reverse its direction again.

In the motor control section of the program. It follows a sequence of sending a signal to the pins on the arduino and in turn switch the LED's and Transistors on and off to make the motor step to that sequence.

I have designed this circuit and program with a chip called the ATtiny85 in mind hence it being such a simple and condense program.


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);

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

void setup() {

int pressed = 1;

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


The schematics of the Circuit for driving a stepper motor from an Arduino
Slider schem lmc8xhsm2d
The breadboard of a circuit to drive a unipolar stepper motor from an Arduino
Slider bb s8dme4ebmg


Similar projects you might like

Simple Programmable Robotic Arm

Project showcase by Ryan Chan

  • 145 respects

Simple Arduino Digital Clock Without RTC

Project in progress by Annlee Fores

  • 80 respects

How to Use Modbus with Arduino

Project tutorial by hwhardsoft

  • 14 respects

More than an Hour Timer

Project tutorial by Ian Cumming

  • 1 comment
  • 4 respects

Simple Arduino Uno - ESP 8266 Integration

Project tutorial by team

  • 75 respects
Add projectSign up / Login