Orbital Shaker

From Hackteria Wiki
Jump to: navigation, search

Orbital shaker.jpg

How to build it

Dimensions

Stepper dim.jpg

Electronics

  • Arduino
  • l293 h-bridge


Arduino Code

/*
 * CIRC-22 Controlling a Stepper Motor - Using an L293
 *
 * A stepper motor will go forward one rotation then back another
 * Using the in built stepper motor library.
 *
 * Arduino Stepper Library Reference - http://www.arduino.cc/en/Reference/Stepper
 *
 * For more details and links visit: http://tinyurl.com/nsuwln
 */

#include <Stepper.h>

#define STEPS 200 //the number of steps for one rotation (this is motor dependant) 
                  //if unsure 200 is a good starting point and the value can be determined
                  //experimentally

Stepper stepper(STEPS, 2, 3, 4, 5);  //declares a stepper motor with coil A connected to out 1 and out 2 (arduino pin 2 and 3)
                                     //and coil B connected to out 3 and out 4 (arduino pin 4 and 5)

int rounds = 2;
int dir = 1;
int count = 0;
int val = 1;
int wait = 500;

const int enable12 = 9;   //bridge 1 and 2 enable (pin 1 on the 16 pin IC) 
const int enable34 = 10;  //bridge 3 and 4 enable (pin 9 on the 16 pin IC)

void setup()
{
  pinMode(enable12, OUTPUT);    //Set the enable12 pin to Output
  pinMode(enable34, OUTPUT);    //Set the enable34 pin to Output  
  digitalWrite(enable12, HIGH); //Set the enable12 pin HIGH to turn the bridges on
  digitalWrite(enable34, HIGH); //Set the enable34 pin HIGH to turn the bridges on  
  stepper.setSpeed(33);           // set the speed of the motor to 50 RPMs
  
  Serial.begin(9600); 
  
}

void loop()
{
  
  val = (1+(analogRead(0)>>3));
    
  stepper.setSpeed(val);           // set the speed of the motor to 50 RPMs
  stepper.step(dir);  //Rotate the motor forward 1 step in a direction
  
  if (count == STEPS * rounds) {
    
    dir = dir * -1;
    count = 0;    
    delay(wait);
    
    }
  
  count = count + 1;
  
}


Maybe try something with the AccelStepper Library? http://www.open.com.au/mikem/arduino/AccelStepper/classAccelStepper.html#details

More Shakers

Shake it baby.png

File:Shake It Baby.pdf

Links

inspired by this entry on thingyverse by jmil http://www.thingiverse.com/thing:5045