MatthieuL
Published

ATTiny85 - Intervallomètre pour Canon

Pour faire suite à un projet existant, je présente une version avancée avec focus et deux options d'intervalle.

IntermediateWork in progress10 hours119
ATTiny85 - Intervallomètre pour Canon

Things used in this project

Hardware components

ATtiny85
Microchip ATtiny85
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
×5
LED (generic)
LED (generic)
×3
Resistor 610 kohm
×2
Resistor 221 ohm
Resistor 221 ohm
×3
SMD Resistor 15k ohm (153)
×1
Resistor 100 ohm
Resistor 100 ohm
×3

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schéma de câblage sur circuit imprimé

Code

attiny85-canon-intervalometer.ino

C/C++
Voici le code source de l'ATTiny85 avec le schéma de branchement. Dans la fonction "setup()" on défini les entrées/sorties et on prépare les variables selon les options. la boucle brincipale du programme "loop()" effectue des prises de photos à intervalles réguliers avec ou sans mise au point (focus) et avec une durée définie. Attention la modification des options se fait uniquement au démarrage du microcontrôleur; on ne peut pas activer/désactiver le focus une fois dans la boucle principale. Veillez à bien programmer les interrupteurs avant d'allumer le circuit.
/*
 *            ATTiny85 8MHz internal
 *                      _____
 *            RESET 5 -|     |- VCC
 *   focus <--  Pin 3 -|     |- Pin 2 --> power LED
 *   photo <--  Pin 4 -|     |- Pin 1 <-- time switch  
 *                GND -|_____|- Pin 0 <-- focus switch 
 *       
 *       VCC
 *        | +
 *       ===  10uF/16v
 *        | 
 *       GND 
 * 
 */

#define INITIAL_DELAY 5000 // pause avant la premire photo (en millisecondes) + focus (si option)
#define FOCUS_DELAY    500 // dure du contact focus (en millisecondes)
#define PHOTO_DELAY    100 // dure du contact photo (en millisecondes)

// intervale entre chaque photo (au moins FOCUS_DELAY+PHOTO_DELAY)
#define INTERVAL_OPTION1 2000 // intervale entre chaque photo #1 (default)
#define INTERVAL_OPTION2 5000 // intervale entre chaque photo #2
 
int photoPin          = 4; // sortie microcontrleur
int focusPin          = 3; // sortie microcontrleur
int powerPin          = 2; // sortie microcontrleur
int intervalOptionPin = 1; // entre microcontrleur (option intervale option1/option2)
int focusOptionPin    = 0; // entre microcontrleur (option focus on/off)

bool focusOption = false;
int IntervalBetweenShots = INTERVAL_OPTION1; // intervale entre chaque photo (en millisecondes)





//////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup()
{
  int timeCount = 0; // compteur

  // input pins :
  pinMode(intervalOptionPin, INPUT); // intervalOptionPin comme entre
  pinMode(focusOptionPin,    INPUT);  // focusOptionPin comme entre
  
  // output pins
  pinMode(photoPin, OUTPUT);       // shutterPin comme sortie
  pinMode(focusPin, OUTPUT);       // focusPin comme sortie
  pinMode(powerPin, OUTPUT);       // powerPin comme sortie
  digitalWrite(photoPin, LOW);     // contact photo teint
  digitalWrite(focusPin, LOW);     // contact focus teint
  digitalWrite(powerPin, LOW);     // LED off
  
  // configuration en fonction de switchs (pullup) :
  if (digitalRead(intervalOptionPin) == LOW) { // contact du bouton = LOW
    IntervalBetweenShots = INTERVAL_OPTION2 - PHOTO_DELAY; 
  }
  else { 
    IntervalBetweenShots = INTERVAL_OPTION1 - PHOTO_DELAY; 
  }
  
  if (digitalRead(focusOptionPin) == LOW) { // contact du bouton = LOW
    focusOption = true; 
    IntervalBetweenShots -= FOCUS_DELAY;
  }
  else { 
    focusOption = false; // pas de focus 
  }
  

  if (focusOption) { digitalWrite(focusPin, HIGH); }  // contact focus 
  // pause de dmarrage (avec clignotement)
  while (timeCount < INITIAL_DELAY){
    digitalWrite(powerPin, LOW);  delay(50); // blink off
    digitalWrite(powerPin, HIGH); delay(50); // blink on
    timeCount += 100;
  }
  digitalWrite(powerPin, LOW);  // LED off
  digitalWrite(focusPin, LOW);  // fin du contact focus
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop()
{
  // prise de photo :
  if (focusOption) {
    digitalWrite(focusPin, HIGH); // contact focus 
    delay(FOCUS_DELAY);           // pause pour le focus
  }  
  digitalWrite(photoPin, HIGH); // contact photo
  delay(PHOTO_DELAY);           // pause pour la photo
  digitalWrite(photoPin, LOW);  // fin du contact photo
  digitalWrite(focusPin, LOW);  // fin du contact focus

  // en pause :
  digitalWrite(powerPin, HIGH);   // LED on
  delay(IntervalBetweenShots);    // pause entre les photos
  digitalWrite(powerPin, LOW);    // LED off
}

Credits

MatthieuL
1 project • 0 followers
Thanks to Piotr Justyna.

Comments