Darstellung der gemessenen Zeit formatieren und auf LCD anzeigen

.
Hallo,

ich bin blutiger Anfänger und habe leider zu wenig Ahnung, daher die Frage

Im Rahmen eines Projektes zur Messung der Belichtungszeit alter Kameras, habe ich ein Messgerät it dem Arduino nachgebaut.

Den code habe ich dabei etwas ergänzt um zum seriellen Monitor auf ein LCD zu kommen.

Das unschöne dabei ist die Zeit korrekt darzustellen, also über eine Sekunde soll es nicht mit 1/xy angezeigt werden.

Die mirkosekunden bekomme ich ja gemessen und umgerechnet, aber die Anzeige analog zu der Einstellung an den Kameras würde dann aber so aussehen:

1sec
1/2 sec
1/4 sec
1/8 sec
1/10
1/25
1/50
1/60

usw.

Hat jemand eine Idee?

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

long Start;           // this is the time in microseconds that the shutter opens (the arduino runs a microsecond clock in the background always - it is reasonably accurate for this purpose)
long Stop;            // this is the time in microseconds that the shutter closes
int Fired = 0;        // this is a flag indicating when the shutter has been fired completely.  when fired =1, the shutter has been fired, and the computer needs to display the information related to the exposure time.
int Risingflag = 0;   // this is a flag that i set in my interrupt routine, Rising flag is set to = 1 when the voltage INCREASES in the interrupt
int Fallingflag = 0;  // this is a flag that i set in the interrupt routine, Fallingflag is set to =1 when the voltage DECREASES in the interrupt

void setup() {                                                  //This part of the program is run exactly once on boot
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
    lcd.setCursor(0,1);
    lcd.print("(c) by xyz");
    lcd.setCursor(0,0);
    lcd.print("Shutterspeed 1.1");

  Serial.begin(9600);                                          //opens a serial connection.
  attachInterrupt(digitalPinToInterrupt(2), CLOCK, CHANGE);    //run the function CLOCK, every time the voltage on pin 2 changes.

}

void loop() {                                                  // this part of the program is run, in order, over and over again, start to finish, unless INTERRUPTED by our interrupt
  if(Risingflag ==1){                       
    Start = micros();       //set the variable Start to current microseconds
  Risingflag=0;           //reset the rising flag to 0, so that this function isnt called again until the shutter actually fires
  }
  if(Fallingflag == 1){
  Stop = micros();      // set the variable Stop to current microseconds
  Fallingflag = 0;      //reset the falling flag to 0, so that this function isnt called again untill the shutter fires again.
  Fired = 1;            // set the fired flag to 1, triggering the calculation of a shutter speed, and its display over the serial monitor.
  }
  if(Fired == 1){                            //if the flag Fired = 1, print this information to the serial monitor"
    Serial.print("Start: ");
    Serial.println(Start);
    Serial.print("Stop: ");
    Serial.println(Stop);
    long Speed = (Stop - Start);      // make a variable called speed, which is the total number of microseconds that the shutter is open for
    Serial.print("Microseconds: ");
    Serial.println(Speed);               //display total microseconds in shutter interval
  

    float SS = (float)Speed/1000000;    // make a variable SS, which is how many seconds that the shutter open for
    float SS2 = 1/SS;                   // make a variable SS2, which is the inverse of the SS, or 1/ the shutter speed
    Serial.print("shutter speed: 1/");
    Serial.println(SS2);                //display the shutter speed
    Serial.println();
    lcd.begin(16, 2);
    lcd.setCursor(0,1);
    lcd.print("1/");
    lcd.print(SS2);
    lcd.print(" sec.");
    lcd.setCursor(0,0);
    lcd.print("Shutter Speed:");
    
   
    Start = 0;                         // reset Start to 0
    Stop = 0;                           //reset Stop to 0 . *** these are not necessarily needed, but makes errors more evident should they occur
    Fired = 0;                          //reset Fired flag to 0, so that the shutter speed will not be calclulated and displayed, until the next full interrupt cycle, where a start and stop time are generated.
  } 
}


void CLOCK(){                     //this is the interrupt function, which is called everytime the voltage on pin 2 changes, no matter where in the main program loop that the computer is currently in
  if(digitalRead(2) == LOW){
    Risingflag = 1;                // if the voltage on pin 2 is lowh, set the Risingflag to 1 : this will trigger the function called Rising from the main loop, which will set a start time
  }
  if(digitalRead(2) == HIGH){        // . if the voltage on pin 2 is high, set the Fallingflag to 1 : this will trigger the function called Falling from the main loop, which will set the stop time, and also set the Fired flag to 1.
    Fallingflag =1;
  }
}

Shutter_Speed_v1_1_Ingo.ino (4.36 KB)

Setze Deinen Code bitte direkt ins Forum. Benutze dazu Codetags (</>-Button oben links im Forumseditor oder [code] davor und [/code] dahinter oder gehe in der IDE auf Bearbeiten - Für Forum kopieren und füge es hier ein.
Dann ist er auch auf mobilen Geräten besser lesbar.
Das kannst Du auch noch nachträglich ändern.

Evtl. die Ausgabe über switch/case machen.

Gruß Tommy

Hallo
wie sieht die Ausgabe auf dem Monitor aus und
wie soll die Ausgabe auf dem LCD Bildschirm aussehen?

statt

lcd.print("1/");
lcd.print(SS2);

halt

if (SS2<1000)
{    lcd.print("1/");
    lcd.print(SS2);
}
else
{  
    lcd.print(SS);
}

Für den Belichtungsmesser brauchst Du außer der Werte der Belichtung auch noch die Reihe der Blenden und der Empfindlichkeit (ISO oder DIN)

Blendereihe, Belichtung und Empfindlichkeit können Ganzschritte, Halbschritte und Drittelschritte ahben

Blendenreihe:
Blende – Olypedia oder Blendenreihe (Optik) – Wikipedia

Ich sehe hier ein Array als gangbaren Weg um Belichtungszeiten in Brüche und Blendenwerte abzulegen und damit rechnen zu können.
Grüße Uwe

so etwa?

klappt nicht

die Anzeige ist dann:

Shutter Speed:
1/0.48 sec.

oder
1/0.51 sec.
bei ca. 5sec.

oder
1/4.45 sec. bei kurzer Zeit

 float SS = (float)Speed/1000000;    // make a variable SS, which is how many seconds that the shutter open for
    float SS2 = 1/SS;                   // make a variable SS2, which is the inverse of the SS, or 1/ the shutter speed
    Serial.print("shutter speed: 1/");
    Serial.println(SS2);                //display the shutter speed
    Serial.println();

    lcd.begin(16, 2);
    lcd.setCursor(0,1);
    if (SS2<1000)
{    lcd.print("1/");
    lcd.print(SS2);
}
else
{ 
    lcd.print(SS);
}
    lcd.print(" sec.");
    lcd.setCursor(0,0);
    lcd.print("Shutter Speed:");

Start: 17131424
Stop: 19278296
Microseconds: 2146872
shutter speed: 1/0.47

Beispiel aus dem Seriellen Monitor (den ich eigentlich nicht nutzen möchte)

wobei 1/0.47 ja auch schon eine unsinnige Angabe ist. Welcher Verschlussöffnungszeit sollte das denn entsprechen?

Gruß Tommy

Tommy56:
wobei 1/0.47 ja auch schon eine unsinnige Angabe ist. Welcher Verschlussöffnungszeit sollte das denn entsprechen?

Naja, eben etwa 2100 Millis bzw. 2 100 000 Micros. Also etwas mehr als 2 Sekunden.
Die Belichtungszeiten von Kameras werden traditionellerweise ja als Reziprokwert angegeben (1/30, 1/60, 1/125 etc.).
Bei Werten größer 1 Sekunde (wie in diesem Fall) ist das zugegeben unüblich, aber auch nicht übermäßig falsch. :slight_smile:

Bei < 1 Sekunde ist die Schreibweise ja auch ok, bei >1 auch bei Kameras eher unüblich.
Der User dürfte mit 2.27 sec auch besser zurecht kommen.

Gruß Tommy

Nun denn, wie gefällt Euch das hier?

void printshutterDuration(char* expected, long shutterDuration);

void setup()
{
  Serial.begin(115200);
  Serial.println(__FILE__);

  printShutterDuration("23    ", 23000000L);         // 23s
  printShutterDuration("2.2   ",  2146872L);         // 2.14s
  printShutterDuration("1.0   ",  1000000L);         // 1s
  printShutterDuration("1/10  ",   100000L);         // 100ms = 1/10s
  printShutterDuration("1/100 ",    10000L);         // 10ms = 1/100s
  printShutterDuration("1/200 ",     5000L);         // 5ms = 1/200s
  printShutterDuration("1/500 ",     2000L);         // 2ms = 1/500s
  printShutterDuration("1/1000",     1000L);         // 1ms = 1/1000s
  printShutterDuration("1/2000",      500L);         // 0.5ms = 1/2000s
  printShutterDuration("1/4000",      250L);         // 0.25ms = 1/4000s
}

void loop()
{
}

// prints shutter speed in human readable form similar to old analog camera settings
void printShutterDuration(char* expected, long shutterDuration)
{
  Serial.print(F("shutter speed: "));
  Serial.print(F("["));
  Serial.print(expected);
  Serial.print(F("]  "));
  if (shutterDuration >= 10000000L)
  {
    // mehr als 10s -> ganzzahlig Sekunden
    Serial.println(shutterDuration / 1000000L);
  }
  else if (shutterDuration >= 1000000L)
  {
    // 1...10s -> Sekunden mit einer Nachkommastelle gerundet
    float SS2 = (float)((shutterDuration / 100000L) + 0.5) / 10.;
    Serial.println(SS2, 1);
  }
  else if (shutterDuration >= 1000L)
  {
    // 1ms...1s -> Ausgabe in 1000stel Sekunden
    Serial.print("1/");
    Serial.println(1000 / (shutterDuration / 1000));
  }
  else
  {
    Serial.print("1/");
    Serial.println(1000000 / shutterDuration);
  }
}

Die Ausgabe aus dem Monitor:

18:27:41.842 -> C:\Users\wno\Documents\Arduino\forum\sketch_jan30a\sketch_jan30a.ino
18:27:41.842 -> shutter speed: [23    ]  23
18:27:41.842 -> shutter speed: [2.2   ]  2.2
18:27:41.842 -> shutter speed: [1.0   ]  1.0
18:27:41.842 -> shutter speed: [1/10  ]  1/10
18:27:41.842 -> shutter speed: [1/100 ]  1/100
18:27:41.842 -> shutter speed: [1/200 ]  1/200
18:27:41.842 -> shutter speed: [1/500 ]  1/500
18:27:41.842 -> shutter speed: [1/1000]  1/1000
18:27:41.842 -> shutter speed: [1/2000]  1/2000
18:27:41.842 -> shutter speed: [1/4000]  1/4000

Anpassung an den real existierenden Code bleibt dem Leser als Übung überlassen :wink:

Danke, das wird wohl mein Sonntagssport werden
aber was ist mit den Zwischenwerten?

Keine Kamera, bzw. Objekte erzeugt die Verschlusszeit exakt, es sind immer Werte daneben real existierend.
Als 1/213 sec oder 0,93 sec.

Du willst ja den tatsächlichen Wert angeben. Da sollte sich der User schon denken können, dass 1/213 wohl der Messwert für 1/200 ist. Wenn Du Beides angeben willst, musst Du mit Bereichen arbeiten: Also von wo bis wo willst Du es 1/200 zurechnen.

Gruß Tommy

Geht unterhalb einer Zehntelsekunde auch, wenn man den Umweg über float geht und keine Nachkommastellen ausgibt:

// prints shutter speed in human readable form similar to old analog camera settings
void printShutterDuration(const char* expected, long shutterDuration)
{
    float SS2;
    
  Serial.print(F("shutter speed: "));
  Serial.print(shutterDuration);
  Serial.print(F("  ["));
  Serial.print(expected);
  Serial.print(F("]  "));
  if (shutterDuration >= 10000000L)
  {
    // mehr als 10s -> ganzzahlig Sekunden
    Serial.println(shutterDuration / 1000000L);
  }
  else if (shutterDuration >= 1000000L)
  {
    // 1...10s -> Sekunden mit einer Nachkommastelle gerundet
    SS2 = (float)((shutterDuration / 100000.) + 0.5) / 10.;
    Serial.println(SS2, 1);
  }
  else if (shutterDuration >= 1000L)
  {
    // 1ms...1s -> Ausgabe in 1000stel Sekunden
    Serial.print("1/");
    SS2 = 1000. / (shutterDuration / 1000.);
    Serial.println(SS2, 0);
  }
  else
  {
    Serial.print("1/");
    Serial.println(1000000 / shutterDuration);
  }
}

Ich habe jetzt die Eingangswerte in die Ausgabe aufgenommen (für Ausrichtung war ich zu faul):

19:55:38.215 -> C:\Users\wno\Documents\Arduino\forum\sketch_jan30a\sketch_jan30a.ino
19:55:38.215 -> shutter speed: 23000000  [23    ]  23
19:55:38.215 -> shutter speed: 2146872  [2.2   ]  2.2
19:55:38.215 -> shutter speed: 1000000  [1.0   ]  1.0
19:55:38.215 -> shutter speed: 765000  [1/xx  ]  1/1
19:55:38.215 -> shutter speed: 234000  [1/xx  ]  1/4
19:55:38.215 -> shutter speed: 100000  [1/10  ]  1/10
19:55:38.215 -> shutter speed: 43000  [1/xxx ]  1/23
19:55:38.215 -> shutter speed: 10000  [1/100 ]  1/100
19:55:38.215 -> shutter speed: 5630  [1/xxx ]  1/178
19:55:38.262 -> shutter speed: 5000  [1/200 ]  1/200
19:55:38.262 -> shutter speed: 2000  [1/500 ]  1/500
19:55:38.262 -> shutter speed: 1230  [1/xxx ]  1/813
19:55:38.262 -> shutter speed: 1000  [1/1000]  1/1000
19:55:38.262 -> shutter speed: 500  [1/2000]  1/2000
19:55:38.262 -> shutter speed: 413  [1/xxxx]  1/2421
19:55:38.262 -> shutter speed: 250  [1/4000]  1/4000

Sind die alten Kameras mit Zentralverschluß, Lamellenverschluß oder Vorhang?

Die Werte der Verschlußzeit, Blende und Empfindlichkeit werden bestimmte Werte verwendet. Außerdem sind zu feine Abstufungen nicht nötig.

Wäre es da nicht besser man nimmt die Reihe und errechnet dazu den Fehler (Faktor nicht Differenz) zur nächsten oberen und unteren Wert?

Grüße Uwe

wno158:
Geht unterhalb einer Zehntelsekunde auch, wenn man den Umweg über float geht und keine Nachkommastellen ausgibt:

// prints shutter speed in human readable form similar to old analog camera settings

void printShutterDuration(const char* expected, long shutterDuration)
{
   float SS2;
   
 Serial.print(F("shutter speed: "));
 Serial.print(shutterDuration);
 Serial.print(F("  ["));
 Serial.print(expected);
 Serial.print(F("]  "));
 if (shutterDuration >= 10000000L)
 {
   // mehr als 10s -> ganzzahlig Sekunden
   Serial.println(shutterDuration / 1000000L);
 }
 else if (shutterDuration >= 1000000L)
 {
   // 1...10s -> Sekunden mit einer Nachkommastelle gerundet
   SS2 = (float)((shutterDuration / 100000.) + 0.5) / 10.;
   Serial.println(SS2, 1);
 }
 else if (shutterDuration >= 1000L)
 {
   // 1ms...1s -> Ausgabe in 1000stel Sekunden
   Serial.print("1/");
   SS2 = 1000. / (shutterDuration / 1000.);
   Serial.println(SS2, 0);
 }
 else
 {
   Serial.print("1/");
   Serial.println(1000000 / shutterDuration);
 }
}




Ich habe jetzt die Eingangswerte in die Ausgabe aufgenommen (für Ausrichtung war ich zu faul):


19:55:38.215 -> C:\Users\wno\Documents\Arduino\forum\sketch_jan30a\sketch_jan30a.ino
19:55:38.215 -> shutter speed: 23000000  [23    ]  23
19:55:38.215 -> shutter speed: 2146872  [2.2   ]  2.2
19:55:38.215 -> shutter speed: 1000000  [1.0   ]  1.0
19:55:38.215 -> shutter speed: 765000  [1/xx  ]  1/1
19:55:38.215 -> shutter speed: 234000  [1/xx  ]  1/4
19:55:38.215 -> shutter speed: 100000  [1/10  ]  1/10
19:55:38.215 -> shutter speed: 43000  [1/xxx ]  1/23
19:55:38.215 -> shutter speed: 10000  [1/100 ]  1/100
19:55:38.215 -> shutter speed: 5630  [1/xxx ]  1/178
19:55:38.262 -> shutter speed: 5000  [1/200 ]  1/200
19:55:38.262 -> shutter speed: 2000  [1/500 ]  1/500
19:55:38.262 -> shutter speed: 1230  [1/xxx ]  1/813
19:55:38.262 -> shutter speed: 1000  [1/1000]  1/1000
19:55:38.262 -> shutter speed: 500  [1/2000]  1/2000
19:55:38.262 -> shutter speed: 413  [1/xxxx]  1/2421
19:55:38.262 -> shutter speed: 250  [1/4000]  1/4000

Das sieht gut aus,
Aber ich brauche die Ausgabe über das LCD
Geht das auch?
Und wo setze ich es dann ein?

Hmmm - ich bin jetzt mal ziemlich boshaft: Ein wenig darfst Du Dich auch bemühen.

Also:
Auch die Klasse LiquidCrystal und das damit erzeugte lcd-Objekt hat eine print()-Methode - die benutzt Du ja auch schon.
Wenn Du vorher den Cursor passend setzt, sollte das mit Ersatz von "Serial" durch "lcd" an den entsprechenden Stellen passen.

Eine Stelle mal zur Anschauung:

    lcd.print("1/");
    SS2 = 1000. / (shutterDuration / 1000.);
    lcd.println(SS2, 0);

Und natürlich brauchst Du die Testausgaben am Anfang der Funktion (shutterDuration, expected) und die Folklore drumherum nicht mehr.

Hallo Walter,

vielen Dank, aber soweit bin ich noch nicht.
Ich hab den Starter Kit seit xmas und arbeite mich durch.

Vielleicht kannst du mit den code reinstellen und ich versuche ihn dann zu verstehen,
mein erster Versuch ihn einzubauen schlug leider fehl.

btw

die Idee hinter dem Aufbau ist, die Verschlüsse, also Lamellen, Schlitz und Blendenverschluss auf ihr Genauigkeit hin zu prüfen, eine kleine Tabelle auf's Handy speichern und bei bedarf vor Ort abgleichen.

Es gibt ja käufliche Geräte um die 150,-- € und dabei ist die Messung wohl auf verschiedene Verschlusstypen hin optimiert.
Ich meine mit der Laserdiode schaff ich eine präzisen Punkt zu erzeugen und egal welcher Verschluss ich habe, es wird immer korrekt gemessen. Bei breiter Lichtquelle sieht das uU anders aus.

Mal sehen was ich ermitteln kann.

Es gibt dann auch noch ein Projekt mit einer steuerbaren Lichtquelle über RGB LEDs die dann anstelle der alten Halogenlichtquelle auf dem Vergrößere zum Einsatz kommt.
Auch da gibt es einige gute Beispiele im WEB

Na gut :wink:
Hier der Code, den ich zum Testen an einem LCD 16x2 verwendet habe.

#include <LiquidCrystal.h>

// test: standard way to connect 16x2 LCD
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

// test data - duration of shutter open in microseconds
// "long" because original forum code uses long.
// Hint: Should be unsigned long.
const long testData[] = { 23000000L, 2146872L, 1000000L, 765000L, 234000L, 100000L, 43000L, 10000L, 5630L, 5000L, 2000L, 1230L, 1000L, 500L, 413L, 250L };
const int numberOfTestData = sizeof(testData) / sizeof(long);

// forward declaration: Put this line before first usage of the function
void printshutterDuration(const long shutterDuration);

//-----------------------------------------------------
void setup()
{
  Serial.begin(115200);
  Serial.println(__FILE__);

  lcd.begin(16, 2);

  // run through test data and print value
  for (int count = 0; count < numberOfTestData; count++)
  {
    printShutterDuration(testData[count]);
    delay(2000);
  }
}

//-----------------------------------------------------
void loop()
{
}

//-----------------------------------------------------
// prints shutter speed in human readable form similar to old analog camera settings
// LCD is cleared completely before output to avoid artifacts of old output
// parameter:
//   long shutterDuration     shutter time open in microseconds
// return:
//   nothing
void printShutterDuration(const long shutterDuration)
{
  float SS2;

  lcd.clear();
  lcd.print("Shutter Speed: ");

  lcd.setCursor(0, 1);
  if (shutterDuration >= 10000000L)
  {
    // mehr als 10s -> ganzzahlig Sekunden
    lcd.print(shutterDuration / 1000000L);
  }
  else if (shutterDuration >= 1000000L)
  {
    // 1...10s -> output seconds with one decimal digit
    SS2 = (float)((shutterDuration / 100000.) + 0.5) / 10.;
    lcd.print(SS2, 1);
  }
  else if (shutterDuration >= 1000L)
  {
    // 1ms...1s -> Output fraction of thousands of a second
    lcd.print("1/");
    SS2 = 1000. / (shutterDuration / 1000.);
    lcd.print(SS2, 0);
  }
  else
  {
    // below one millisecond: Output fraction of thousands of a second
    lcd.print("1/");
    lcd.print(1000000 / shutterDuration);
  }
}

Deinen ganzen Sketch kenne ich ja nicht, deshalb aus dem Bauch die Anleitung zum Einbinden:
Die Funktion printShutterDuration packst Du ans Ende Deines Sketchs.
Vor setup() fügst Du die Forward-Deklaration ein.
Wenn der Wert für "Speed" berechnet ist rufst Du damit die Funktion auf, die Rechnerei mit SS und SS2 entfernst Du.

Hi,
ich bekomme es nicht hin.
Das ist der Ursprungscode, mit einer schon mal recht guten Anzeige:

[code]
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

long Start;                                                  // this is the time in microseconds that the shutter opens (the arduino runs a microsecond clock in the background always - it is reasonably accurate for this purpose)
long Stop;                                                   // this is the time in microseconds that the shutter closes
int Fired = 0;                                               // this is a flag indicating when the shutter has been fired completely.  when fired =1, the shutter has been fired, and the computer needs to display the information related to the exposure time.
int Risingflag = 0;                                          // this is a flag that i set in my interrupt routine, Rising flag is set to = 1 when the voltage INCREASES in the interrupt
int Fallingflag = 0;                                         // this is a flag that i set in the interrupt routine, Fallingflag is set to =1 when the voltage DECREASES in the interrupt

void setup() {                                               //This part of the program is run exactly once on boot
  
    lcd.begin(16, 2);                                        // set up the LCD's number of columns and rows:
    lcd.setCursor(0,1);                                      // Print a message to the LCD.
    lcd.print("(c) by murphy");
    lcd.setCursor(0,0);
    lcd.print("Shutterspeed x.y");

   attachInterrupt(digitalPinToInterrupt(2), CLOCK, CHANGE); //run the function CLOCK, every time the voltage on pin 2 changes.

}

void loop() {                                                // this part of the program is run, in order, over and over again, start to finish, unless INTERRUPTED by our interrupt
  if(Risingflag ==1){                       
    Start = micros();                                        // set the variable Start to current microseconds
  Risingflag=0;                                              // reset the rising flag to 0, so that this function isnt called again until the shutter actually fires
  }
  if(Fallingflag == 1){
  Stop = micros();                                           // set the variable Stop to current microseconds
  Fallingflag = 0;                                           // reset the falling flag to 0, so that this function isnt called again untill the shutter fires again.
  Fired = 1;                                                 // set the fired flag to 1, triggering the calculation of a shutter speed, and its display over the serial monitor.
  }
  if(Fired == 1){                                            // if the flag Fired = 1, print this information to the serial monitor"
    long Speed = (Stop - Start);                             // make a variable called speed, which is the total number of microseconds that the shutter is open for
    float SS = (float)Speed/1000000;                         // make a variable SS, which is how many seconds that the shutter open for
    int SS2 = 1/SS;                                          // make a variable SS2, which is the inverse of the SS, or 1/ the shutter speed
    lcd.begin(16, 2);
    lcd.setCursor(0,1);
    if(SS >=1)
    {
    lcd.print(SS);
    lcd.print(" sec.");
    lcd.setCursor(0,0);
    lcd.print("Shutter Speed:"); 
    }
    else
    {
    lcd.print("1/");
    lcd.print(SS2);
    lcd.print(" sec.");
    lcd.setCursor(0,0);
    lcd.print("Shutter Speed:"); 
    }

  
    Start = 0;                                               // reset Start to 0
    Stop = 0;                                                // reset Stop to 0 . *** these are not necessarily needed, but makes errors more evident should they occur
    Fired = 0;                                               // reset Fired flag to 0, so that the shutter speed will not be calclulated and displayed, until the next full interrupt cycle, where a start and stop time are generated.
  } 
}



void CLOCK(){                                                // this is the interrupt function, which is called everytime the voltage on pin 2 changes, no matter where in the main program loop that the computer is currently in
  if(digitalRead(2) == LOW){
    Risingflag = 1;                                          // if the voltage on pin 2 is lowh, set the Risingflag to 1 : this will trigger the function called Rising from the main loop, which will set a start time
  }
  if(digitalRead(2) == HIGH){                                // if the voltage on pin 2 is high, set the Fallingflag to 1 : this will trigger the function called Falling from the main loop, which will set the stop time, and also set the Fired flag to 1.
    Fallingflag =1;
  }
}

[/code]