Victor Aguilar
Published © GPL3+

Telescope & DSRL Zoom Controller

This projects automatically the focus of a camera when capturing still images

IntermediateProtip5 hours1,087
Telescope & DSRL Zoom Controller

Things used in this project

Hardware components

ATtiny85
Microchip ATtiny85
×1
uln2003
×1
5v stepper motor 48byj-48
×1
Resistor 220 ohm
Resistor 220 ohm
×5
1.8k ohm resistor
×1
RJ11 connector
×2
RJ11 cable
×1
jumper cable
×1
4 x 4 breadboard
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
solder paste
solder flux

Story

Read more

Code

Focuser

Arduino
int motorPin1 = 0;
int motorPin2 = 1;
int motorPin3 = 3;
int motorPin4 = 4; 
int motorSpeed = 1200;
int count = 0;
int countsperrev = 512;
int lookup[8] = {B01000, B01100, B00100, B00110, B00010, B00011, B00001, B01001};
int controlPin = A1;
int val = 0;
int opCode = 0;
int stepSize = 5;
boolean busy = false;

void setup() {
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT); 
  pinMode(controlPin, INPUT); 
}
void moveBackward()
{
  for (int s = 0; s < stepSize; s++) {
    for(int i = 0; i < 8; i++)
    {
   setOutput(i);
   delayMicroseconds(motorSpeed);
    }
  }
}
void moveForward()
{
  for (int s = 0; s < stepSize; s++) {
    for(int i = 7; i >= 0; i--)
    {
   setOutput(i);
   delayMicroseconds(motorSpeed);
    }
  }
}
void setOutput(int out)
{
  digitalWrite(motorPin1, bitRead(lookup[out], 0));
  digitalWrite(motorPin2, bitRead(lookup[out], 1));
  digitalWrite(motorPin3, bitRead(lookup[out], 2));
  digitalWrite(motorPin4, bitRead(lookup[out], 3));
}
void moveB10() { 
if (busy == false) {  // do it once then wait for button release
    for (int i = 9; i >= 0; i--) {
    moveBackward(); }
    busy = true; }
}
void moveB1() { 
  if (busy == false) {
    moveBackward();
    busy = true; }
}
void moveF1() { 
  if (busy == false) {
    moveForward();
    busy = true; }
}
void loop() {
val = analogRead(controlPin);
  if (val < 102) {
    opCode = 0;
  } else if (val < 307) {
    opCode = 1;
  } else if (val < 512) {
    opCode = 2;
  } else if (val < 717) {
    opCode = 3;
  } else if (val < 922) {
    opCode = 4;
  } else {
    opCode = 5;
  }
  switch(opCode) {
    case 0 : busy = false; delay(100); break;
    case 1 : moveF1(); break;
    case 2 : moveForward(); break;
    case 3 : moveB10(); break;
    case 4 : moveBackward(); break;
    case 5 : moveB1(); break;
  }
}

Credits

Victor Aguilar
2 projects • 35 followers
Electronic Engineering
Contact

Comments

Please log in or sign up to comment.