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…

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:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342

#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);
}
}
Généré avec Hugo
Thème Stack conçu par Jimmy