Arduino PhotoLab – Schéma

Comme promis, voici le schéma de la carte principale du montage Arduino PhotoLab

Je débute avec Eagle alors mon schéma n’est pas forcément très clair, mais bon…

photolab

Le voici au format Eagle

  • Prise SENSORS: branchement des capteurs
  • Prise TTL: Branchement d’un convertisseur USB/TTL pour reprogrammer l’arduino.
  • Prise STROBE: Sortie pour la prise de commande du flash ou de l’appareil photo suivant l’usage.
  • Prise POWER: Alimentation 5V par transfo ou pack de piles.

Les 4 boutons permettent de se ballader dans les menus pour choisir les capteurs et changer les valeurs.

Il reste quelques ports dispo sur l’arduino pour un usage futur…

Je n’ai pas mis le schéma des capteurs. Vous pouvez en trouver plein sur le playground arduino ici. Il suffit d’utiliser une prise jack 3.5mm male et de la brancher sur la prise SENSORS. Vous avez alors VCC,  GND, DATA. Où DATA est un voltage entre 0 et 5 v.

Je ne suis pas sûr que mon système soit utilisable tel quel chez vous, mais vous pouvez vous en inspirer pour créer le votre. En tout cas, chez moi ça marche très bien 🙂

Pour ce qui est du code, le voici:

[code]

#include <LCD4Bit.h>

//BUG ?
#undef int()
// END BUG
#include <stdio.h>

LCD4Bit lcd = LCD4Bit(2);

//#define DEBUG 1

// global defs
#define shootPin  11
#define sensorPin 4
#define bt1Pin 3
#define bt2Pin 4
#define bt3Pin 5
#define bt4Pin 6
#define ledPin 13 //digital

#define MAXMENU 4

#define MENUSENSOR 1
#define MENUSTROBEDELAY 2
#define MENURUN 3

#define MODESENSOR 1

#define NO 0
#define YES 1
#define TEST 2

#define SOUNDSENSOR 0
#define IRSENSOR 1
#define CONTACTSENSOR 2
#define LIGHTSENSOR 3

volatile unsigned int menu0Pos = MENUSENSOR;
volatile unsigned int debounce = 0;
volatile unsigned int modeSensor = 0;
volatile unsigned int modeDrop= 0;
volatile unsigned int modeApp = MODESENSOR;
volatile unsigned int sensorType = IRSENSOR;
volatile unsigned int firstPass = 0;
volatile unsigned int sndLevel = 0;

volatile int strobeDelay = 10;

void setup() {
pinMode(ledPin,OUTPUT);
pinMode(shootPin,OUTPUT);
pinMode(bt1Pin,INPUT);
pinMode(bt2Pin,INPUT);
pinMode(bt3Pin,INPUT);
pinMode(bt4Pin,INPUT);
setLed(1);
lcd.init();

/*lcd.commandWrite(0x0F);//cursor on, display on, blink on.  (nasty!)
*/
lcd.clear();
lcd.printIn(« equinoxefr.org »);
lcd.cursorTo(2, 0);  //line=2, x=0.
lcd.printIn(« Photo lab v0.3″);
delay(2000);
fillLine(2, »FW Trigger »);
delay(2000);
lcd.clear();
setLed(0);
#ifdef DEBUG
Serial.begin (9600);
Serial.println(« start »);                // a personal quirk
#endif
}

void loop() {
int val=0;
int keyFactor=1;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  SENSOR SECTION
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (modeSensor)
{
while (1)
{
val=analogRead(sensorPin);
switch (sensorType)
{
case LIGHTSENSOR:

if (val > 500)
{
shoot();
}
//      char buffer[50];
//      strobeDelay=getValue(strobeDelay,-1,9999);
//      itoa(strobeDelay,buffer,DEC);
//      fillLine(2,buffer);
break;

case IRSENSOR:

if (val < 900)
{
shoot();
}
//      char buffer[50];
//      strobeDelay=getValue(strobeDelay,-1,9999);
//      itoa(strobeDelay,buffer,DEC);
//      fillLine(2,buffer);
break;

case SOUNDSENSOR:
if (firstPass)
{
fillLine(2, »Getting snd level »);
sndLevel=soundLevel();
clearLcdLine(2);
firstPass=0;
}
val = analogRead(sensorPin);

if ((val > (sndLevel + 40)) && (val < 1024))
{
shoot();
}

break;

case CONTACTSENSOR:
if ( val < 500)
{
shoot();
}
break;
}
}
}

/*
#ifdef DEBUG
Serial.println(menu0Pos,DEC);
#endif
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  MENU SECTION
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

switch (menu0Pos)
{
case MENUSTROBEDELAY:
fillLine(1, »Strobe delay ms »);
modeSensor=0;
strobeDelay=getValue(strobeDelay,-1,9999);
if (strobeDelay==-1)
{
fillLine(2, »not used »);
}
else
{
char buffer[50];
itoa(strobeDelay,buffer,DEC);
fillLine(2,buffer);
}
break;
case MENUSENSOR:
fillLine(1, »Select sensor »);
sensorType=getValue(sensorType,0,3);
switch(sensorType)
{
case SOUNDSENSOR:
fillLine(2, »SOUND »);
firstPass=1;
break;
case IRSENSOR:
fillLine(2, »IR BARRIER »);
break;
case CONTACTSENSOR:
fillLine(2, »CONTACT »);
break;
case LIGHTSENSOR:
fillLine(2, »IR LIGHT »);
break;
}
//digitalWrite(ledPin, HIGH);
modeSensor=0;
break;

case MENURUN:
if (!modeSensor)
{
fillLine(1, »***SHOOT MODE*** »);
}
modeSensor=1;
break;
}
getMenu();
}

//
//  soundLevel()
//
int soundLevel()
{
int value=analogRead(sensorPin);

Serial.println(« Getting sound level… »);
for(int i=0; i < 50 && !modeSensor; i++)
{
value = ( value + analogRead(sensorPin) ) / 2;
delay(50);
}
Serial.println(« Done! »);

return value;

}

void clearLcdLine(int line)
{
lcd.cursorTo(line, 0);
lcd.printIn( »                     « );
}

void fillLine(int line,char* str)
{
char buffer[21];
int len=strlen(str);
for (int i=0;i<20;i++)
{
if (i < len)
{
buffer[i]=str[i];
}
else
{
buffer[i]=’ ‘;
}
}
lcd.cursorTo(line,0);
lcd.printIn(buffer);
}

void shoot()
{
if (strobeDelay > 0 )
{
delay(strobeDelay);
}
digitalWrite(shootPin,HIGH);
delay(10);
digitalWrite(shootPin,LOW);
fillLine(2, »Shoot ! »);
digitalWrite(ledPin,HIGH);
delay(3000);
digitalWrite(ledPin,LOW);
clearLcdLine(2);

}

void getMenu()
{
int bt1=digitalRead(bt3Pin);
int bt2=digitalRead(bt4Pin);

if (!bt1 && !bt2)
{
return;
}

if (bt1 && menu0Pos < MAXMENU)
{
menu0Pos++;
}
if (bt2 && menu0Pos > 0)
{
menu0Pos–;
}

}

int getValue(int value, int mini, int maxi)
{
unsigned int keyFactor=1;
int bt1=digitalRead(bt1Pin);
int bt2=digitalRead(bt2Pin);

if  (value < 50 )
{
keyFactor=1;
}
else
{
if (value >= 50 )
{
keyFactor=10;
}
}
if  ( bt1 )
{
value+=keyFactor;
}
if  ( bt2 )
{
value-=keyFactor;
}

if ( value <= mini)
{
value=mini;
}
else
{
if (value >= maxi)
{
value=maxi;
}
}
/*
if ( bt1 && bt2 )
{
modeSensor=0;
fillLine(2, »switch off »);
}
*/
return value;

}

void setLed(int value)
{
if (value)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
}
[/code]