yilmazyurdakul
Published

Retro View Timer

Analog view timer based on stepper motor and easy driver, controlled by Arduino Nano with two buttons.

IntermediateFull instructions provided2,449
Retro View Timer

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
You can use any other
×1
Big Easy Driver
SparkFun Big Easy Driver
Possible with H-Bridge and unipolar steppers
×1
NEMA 17 Stepper Motor
OpenBuilds NEMA 17 Stepper Motor
Small setepper is enough for small design. You can get it from DVD-ROM or laser printer
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
LED (generic)
LED (generic)
×2
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×2

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Main Circuit

Main Circuit .fzz

Code

Arduino Code - TR

Arduino
Explained in Turkish
int dir = 12;
int pulse = 11;
int drvAktif = 10;

int saatAyar = 125;

int buton1 = 8;
int buton2 = 7;
int ledPin = 9;

int sayac = 0;
int uyariSayaci = 0;
int limit = 1;
int limitLed = 0;
int uyariLimit;
int sayacAktif = false;

int t;
int t2;

void setup() {
  Serial.begin(9600);
  pinMode(buton1, INPUT);
  pinMode(buton2, INPUT);

  pinMode(ledPin, OUTPUT);
  pinMode(drvAktif, OUTPUT);
  pinMode(dir, OUTPUT);
  pinMode(pulse, OUTPUT);

  digitalWrite(dir, LOW);
  digitalWrite(pulse, LOW);
  digitalWrite(drvAktif, HIGH);
}
void loop() {
  //---------Buton Kontrolleri---------------------------------

  while (digitalRead(buton2) == HIGH && sayacAktif == false) {
    t++;
    delay(1);
  }
  if (t > 500) {
    saatAyar = 125;
    t = 0;

  }
  if (t > 50 && t < 500) {
    saatAyar = saatAyar + 125;
    delay(100);
    t = 0;
  }
  //----------Set ayarları---------------------------------------
  while (digitalRead(buton1) == HIGH && sayacAktif == false) {
    t2++;
    delay(1);
  }
  if (t2 < 500 && t2 > 50) {
    limit = limit + 1;
    delay(100);
    if (limit > 5) {
      limit = 1;
    }
    while (limitLed < limit) {
      analogWrite(ledPin, 200);
      delay(150);
      analogWrite(ledPin, 0);
      delay(200);
      limitLed = limitLed + 1;
    }
    limitLed = 0;
    t2 = 0;
  }

  if (t2 > 500) {
    sayac = 0;
    sayacAktif = true;
    delay(100);
    t2 = 0;
  }

  Serial.print(limit);
  Serial.print("\t");
  Serial.print(sayac);
  Serial.print("\t");
  Serial.print(saatAyar);
  Serial.print("\t");
  Serial.println(sayacAktif);
  delay(1);
  //---------Buton Kontrolleri---------------------------------
  while (sayacAktif == true && sayac < limit) {
    //---------uyarı bölümü----------------------------------
    uyariLimit = limit - sayac;
    while (uyariLimit > uyariSayaci) {
      delay(300);
      analogWrite(ledPin, 200);
      delay(150);
      analogWrite(ledPin, 0);
      delay(300);
      uyariSayaci = uyariSayaci + 1;
    }
    uyariSayaci = 0;
    //---------uyarı bölümü----------------------------------
    geriSayim();
    sayac = sayac + 1;
    if ( sayac == limit) {
      sayacAktif = false;
      digitalWrite(drvAktif, HIGH);
    }
  }
}
void geriSayim() {

  digitalWrite(drvAktif, LOW);
  digitalWrite(dir, LOW);
  for (int i = 0; i <= 240; i++) {
    analogWrite(ledPin, i);
    digitalWrite(pulse, HIGH);
    delayMicroseconds(50);
    digitalWrite(pulse, LOW);
    delay(saatAyar);

  }

  delay(100);
  digitalWrite(dir, HIGH);
  for (int i = 0; i <= 240; i++) {
    analogWrite(ledPin, 240 - i);
    digitalWrite(pulse, HIGH);
    delayMicroseconds(50);
    digitalWrite(pulse, LOW);
    delayMicroseconds(2500);
  }
}

Arduino Code - En

Arduino
Explained in English
int dir = 12;
int pulse = 11;
int drvActive = 10;

int timeSet = 125;

int buton1 = 8;
int buton2 = 7;
int ledPin = 9;

int counter = 0;
int warnCount = 0;
int limit = 1;
int limitLed = 0;
int warnLimit;
int counterActive = false;

int t;
int t2;

void setup() {
  Serial.begin(9600);
  pinMode(buton1, INPUT);
  pinMode(buton2, INPUT);

  pinMode(ledPin, OUTPUT);
  pinMode(drvActive, OUTPUT);
  pinMode(dir, OUTPUT);
  pinMode(pulse, OUTPUT);

  digitalWrite(dir, LOW);
  digitalWrite(pulse, LOW);
  digitalWrite(drvActive, HIGH);
}
void loop() {
  //---------Button Controller---------------------------------

  while (digitalRead(buton2) == HIGH && counterActive == false) {
    t++;
    delay(1);
  }
  if (t > 500) {
    timeSet = 125;
    t = 0;

  }
  if (t > 50 && t < 500) {
    timeSet = timeSet + 125;
    delay(100);
    t = 0;
  }
  //----------Set Settings---------------------------------------
  while (digitalRead(buton1) == HIGH && counterActive == false) {
    t2++;
    delay(1);
  }
  if (t2 < 500 && t2 > 50) {
    limit = limit + 1;
    delay(100);
    if (limit > 5) {
      limit = 1;
    }
    while (limitLed < limit) {
      analogWrite(ledPin, 200);
      delay(150);
      analogWrite(ledPin, 0);
      delay(200);
      limitLed = limitLed + 1;
    }
    limitLed = 0;
    t2 = 0;
  }

  if (t2 > 500) {
    counter = 0;
    counterActive = true;
    delay(100);
    t2 = 0;
  }

  Serial.print(limit);
  Serial.print("\t");
  Serial.print(counter);
  Serial.print("\t");
  Serial.print(timeSet);
  Serial.print("\t");
  Serial.println(counterActive);
  delay(1);
  //---------Buton Controller---------------------------------
  while (counterActive == true && counter < limit) {
    //---------Warning Part----------------------------------
    warnLimit = limit - counter;
    while (warnLimit > warnCount) {
      delay(300);
      analogWrite(ledPin, 200);
      delay(150);
      analogWrite(ledPin, 0);
      delay(300);
      warnCount = warnCount + 1;
    }
    warnCount = 0;
    //---------Warning Part----------------------------------
    countDown();
    counter = counter + 1;
    if ( counter == limit) {
      counterActive = false;
      digitalWrite(drvActive, HIGH);
    }
  }
}
void countDown() {
//------------Countdown Starts here---------------------
  digitalWrite(drvActive, LOW);
  digitalWrite(dir, LOW);
  for (int i = 0; i <= 240; i++) {
    analogWrite(ledPin, i);
    digitalWrite(pulse, HIGH);
    delayMicroseconds(50);
    digitalWrite(pulse, LOW);
    delay(timeSet);

  }

  delay(100);
  digitalWrite(dir, HIGH);
  for (int i = 0; i <= 240; i++) {
    analogWrite(ledPin, 240 - i);
    digitalWrite(pulse, HIGH);
    delayMicroseconds(50);
    digitalWrite(pulse, LOW);
    delayMicroseconds(2500);
  }
}

Credits

yilmazyurdakul
9 projects • 27 followers
Contact

Comments

Please log in or sign up to comment.