Arduino nano sketch wont validate/wont upload.

Thread Starter

gene-stevo

Joined Feb 22, 2019
13
Hi Folks, I'm trying to use a sketch (not my work) to control a high speed flash however when I try to validate it I get the error message: 'reading' was not declared in this scope. A certain amount of code is commented out as the sketch is a dual purpose solution for either controlling as laser trigger or a piezo vibration trigger. here is the complete sketch...There is also a screen shot of the error as shown. Thanks for reading, Cheers, Eugene.
Verify error.png
C++:
/* This program is used as a laser trigger and/or sound trigger for high-speed photography<br>  ---> Made by Sander Vanhee <--

push button to activate program
Activate laser or sound trigger
delay
open camera shutter (manual for now)
drop an object
laser barrier or piezo sensor gets triggered
laser off
wait the delay set by potentiometer
trigger flash
delay
close camera shutter
delay
*/

int laserPin = 12;        // red wire from laser
int potPin = 0;           // potentiometer to read delay
int optoPin = 8;          // towards the optocoupler
int buttonApin = 2;       // pushbutton
int photocellPin = A1;    // the cell and 10K pulldown are connected to A1
int photocellReading;     // the analog reading from the sensor divider
int PiezoPin = A2;         // the Piezo is connected to a2
int PiezoReading;         // the analog reading from the sensor divider

void setup(){
  // We'll send debugging information via the Serial monitor
    Serial.begin(9600);
   
    //#define photocellPin 1
    pinMode(laserPin, OUTPUT);
    pinMode(buttonApin, INPUT);
    pinMode(photocellPin, INPUT_PULLUP);
    pinMode(PiezoPin, INPUT);
    pinMode(optoPin, OUTPUT);
    pinMode(potPin, INPUT_PULLUP);
    }

void loop() {
  // check if button is pressed, only continue when pressed.
    Serial.println("Waiting for buttonpress...");

if (digitalRead(buttonApin) == HIGH) {  // start program if button is pressed
    //start if(buttonpressed) loop
    Serial.println("Button pressed");
     
// Read value of potentiometer  
    int reading  = analogRead(potPin);
    Serial.println("reading potentiometer");
    Serial.println(reading);
    reading = map(reading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)

delay(50);


/* We'll put the laser parts in comments to isolate them from the Piezo code

// Activate laser
    digitalWrite(laserPin, HIGH);
    Serial.println("Laser Activated");
   
delay(1000); // delay before open shutter

Serial.println("Drop object");

  // read the value of the photocellPin
    int photocellReading  = digitalRead(photocellPin); //read value photocell and print it
    Serial.println(photocellReading);
   
  //Check if laser is broken
while (digitalRead(photocellPin)==HIGH){
  Serial.println("Laser uninterrupted");
    int photocellReading  = digitalRead(photocellPin); //read value photocell
    Serial.println(photocellReading);
   
// as long as the laser is not broken, this "while" statement will loop.
    // when the laser is broken, the program will continue.
   
  // laser off
  // turn laser off to not show up in the picture
  // digitalWrite(laserPin, LOW);
*/

// what follows is the piezo code
PiezoReading = analogRead(PiezoPin);
Serial.print("Analog reading = ");
Serial.println(PiezoReading);     // the raw analog readingwhile (analogRead(PiezoPin)<1){
  Serial.println("no sound detected");
    int PiezoReading  = analogRead(PiezoPin); //read value photocell
    Serial.println(PiezoReading);
    }
   
    // Wait the amount indicated by the value of potentiometer
    // give the waves time to rise back to the surface
delay(reading);
 
  //trigger flash - send signal from pin 8
    digitalWrite(8, HIGH);
    Serial.println("FLASH fired");
    delay(1000);
    digitalWrite(8, LOW);
   
    //wait for flash light to die down
    delay(200);

    //close camera shutter
   
    Serial.println("END");
    // END OF (buttonpressed) while loop
 
  digitalWrite(laserPin, LOW);
}}

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}
 

djsfantasi

Joined Apr 11, 2010
9,156
Hi Folks, I'm trying to use a sketch (not my work) to control a high speed flash however when I try to validate it I get the error message: 'reading' was not declared in this scope. A certain amount of code is commented out as the sketch is a dual purpose solution for either controlling as laser trigger or a piezo vibration trigger. here is the complete sketch...
C++:
/* This program is used as a laser trigger and/or sound trigger for high-speed photography<br>  ---> Made by Sander Vanhee <--

push button to activate program
Activate laser or sound trigger
delay
open camera shutter (manual for now)
drop an object
laser barrier or piezo sensor gets triggered
laser off
wait the delay set by potentiometer
trigger flash
delay
close camera shutter
delay
*/

int laserPin = 12;        // red wire from laser
int potPin = 0;           // potentiometer to read delay
int optoPin = 8;          // towards the optocoupler
int buttonApin = 2;       // pushbutton
int photocellPin = A1;    // the cell and 10K pulldown are connected to A1
int photocellReading;     // the analog reading from the sensor divider
int PiezoPin = A2;         // the Piezo is connected to a2
int PiezoReading;         // the analog reading from the sensor divider

void setup(){
  // We'll send debugging information via the Serial monitor
    Serial.begin(9600);
   
    //#define photocellPin 1
    pinMode(laserPin, OUTPUT);
    pinMode(buttonApin, INPUT);
    pinMode(photocellPin, INPUT_PULLUP);
    pinMode(PiezoPin, INPUT);
    pinMode(optoPin, OUTPUT);
    pinMode(potPin, INPUT_PULLUP);
    }

void loop() {
  // check if button is pressed, only continue when pressed.
    Serial.println("Waiting for buttonpress...");

if (digitalRead(buttonApin) == HIGH) {  // start program if button is pressed
    //start if(buttonpressed) loop
    Serial.println("Button pressed");
     
// Read value of potentiometer  
    int reading  = analogRead(potPin);
    Serial.println("reading potentiometer");
    Serial.println(reading);
    reading = map(reading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)

delay(50);


/* We'll put the laser parts in comments to isolate them from the Piezo code

// Activate laser
    digitalWrite(laserPin, HIGH);
    Serial.println("Laser Activated");
   
delay(1000); // delay before open shutter

Serial.println("Drop object");

  // read the value of the photocellPin
    int photocellReading  = digitalRead(photocellPin); //read value photocell and print it
    Serial.println(photocellReading);
   
  //Check if laser is broken
while (digitalRead(photocellPin)==HIGH){
  Serial.println("Laser uninterrupted");
    int photocellReading  = digitalRead(photocellPin); //read value photocell
    Serial.println(photocellReading);
   
// as long as the laser is not broken, this "while" statement will loop.
    // when the laser is broken, the program will continue.
   
  // laser off
  // turn laser off to not show up in the picture
  // digitalWrite(laserPin, LOW);
*/

// what follows is the piezo code
PiezoReading = analogRead(PiezoPin);
Serial.print("Analog reading = ");
Serial.println(PiezoReading);     // the raw analog readingwhile (analogRead(PiezoPin)<1){
  Serial.println("no sound detected");
    int PiezoReading  = analogRead(PiezoPin); //read value photocell
    Serial.println(PiezoReading);
    }
   
    // Wait the amount indicated by the value of potentiometer
    // give the waves time to rise back to the surface
delay(reading);
 
  //trigger flash - send signal from pin 8
    digitalWrite(8, HIGH);
    Serial.println("FLASH fired");
    delay(1000);
    digitalWrite(8, LOW);
   
    //wait for flash light to die down
    delay(200);

    //close camera shutter
   
    Serial.println("END");
    // END OF (buttonpressed) while loop
 
  digitalWrite(laserPin, LOW);
}}

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}
Whoever wrote the sketch is unfamiliar with how to code for an Arduino.

The main loop contains no code. The setup doesn’t define anything. For example, the potentiometer pin at least should be defined in setup(). Plus the laser or piezo should be defined as well.

Everything is defined in the global section, which is usually only used for global variable and library initialization.

The variable reading is initialized in one code block and then it is attempted to be used outside code block. That will give you the “‘reading’ is not declared inside this scope”.

It’s a wonder if this ever worked. You need to separate the code into global definitions, hardware/library setup and the main loop. And, you need to declare variable outside of the if, while, or for code blocks, if you need the value outside any of them.
 

Thread Starter

gene-stevo

Joined Feb 22, 2019
13
Whoever wrote the sketch is unfamiliar with how to code for an Arduino.

The main loop contains no code. The setup doesn’t define anything. For example, the potentiometer pin at least should be defined in setup(). Plus the laser or piezo should be defined as well.

Everything is defined in the global section, which is usually only used for global variable and library initialization.

The variable reading is initialized in one code block and then it is attempted to be used outside code block. That will give you the “‘reading’ is not declared inside this scope”.

It’s a wonder if this ever worked. You need to separate the code into global definitions, hardware/library setup and the main loop. And, you need to declare variable outside of the if, while, or for code blocks, if you need the value outside any of them.
Thanks so much for your prompt response. Though I admit to not understanding much of it. The odd thing is the original version didn't mention the piezo stuff at all, just the laser stuff. I've build a rig using just the laser trigger stuff and it works perfectly. Once again thank you for your timely help. Cheers,
Eugene.
 

djsfantasi

Joined Apr 11, 2010
9,156
The error message is pretty clear. The variable 'reading' wasn't declared in a way that allows it to be used.

I didn't see it declared anywhere in the code you posted. Could it be in a header file?
It’s declared inside an “if” code block.
Hence, it’s only available within that block.
 

djsfantasi

Joined Apr 11, 2010
9,156
More info...

  • line 43 starts the “if” code block
  • line 48 defines the variable ‘reading’ as an int
  • line 91 is the end of the code block; and the end of the scope of the ‘reading’ variable
  • line 95 is where ‘reading’ is referenced and not defined
 

s14rs4

Joined Sep 15, 2016
75
Hi Folks, I'm trying to use a sketch (not my work) to control a high speed flash however when I try to validate it I get the error message: 'reading' was not declared in this scope. A certain amount of code is commented out as the sketch is a dual purpose solution for either controlling as laser trigger or a piezo vibration trigger. here is the complete sketch...There is also a screen shot of the error as shown. Thanks for reading, Cheers, Eugene.
View attachment 201304
C++:
/* This program is used as a laser trigger and/or sound trigger for high-speed photography<br>  ---> Made by Sander Vanhee <--

push button to activate program
Activate laser or sound trigger
delay
open camera shutter (manual for now)
drop an object
laser barrier or piezo sensor gets triggered
laser off
wait the delay set by potentiometer
trigger flash
delay
close camera shutter
delay
*/

int laserPin = 12;        // red wire from laser
int potPin = 0;           // potentiometer to read delay
int optoPin = 8;          // towards the optocoupler
int buttonApin = 2;       // pushbutton
int photocellPin = A1;    // the cell and 10K pulldown are connected to A1
int photocellReading;     // the analog reading from the sensor divider
int PiezoPin = A2;         // the Piezo is connected to a2
int PiezoReading;         // the analog reading from the sensor divider

void setup(){
  // We'll send debugging information via the Serial monitor
    Serial.begin(9600);

    //#define photocellPin 1
    pinMode(laserPin, OUTPUT);
    pinMode(buttonApin, INPUT);
    pinMode(photocellPin, INPUT_PULLUP);
    pinMode(PiezoPin, INPUT);
    pinMode(optoPin, OUTPUT);
    pinMode(potPin, INPUT_PULLUP);
    }

void loop() {
  // check if button is pressed, only continue when pressed.
    Serial.println("Waiting for buttonpress...");

if (digitalRead(buttonApin) == HIGH) {  // start program if button is pressed
    //start if(buttonpressed) loop
    Serial.println("Button pressed");
  
// Read value of potentiometer
    int reading  = analogRead(potPin);
    Serial.println("reading potentiometer");
    Serial.println(reading);
    reading = map(reading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)

delay(50);


/* We'll put the laser parts in comments to isolate them from the Piezo code

// Activate laser
    digitalWrite(laserPin, HIGH);
    Serial.println("Laser Activated");

delay(1000); // delay before open shutter

Serial.println("Drop object");

  // read the value of the photocellPin
    int photocellReading  = digitalRead(photocellPin); //read value photocell and print it
    Serial.println(photocellReading);

  //Check if laser is broken
while (digitalRead(photocellPin)==HIGH){
  Serial.println("Laser uninterrupted");
    int photocellReading  = digitalRead(photocellPin); //read value photocell
    Serial.println(photocellReading);

// as long as the laser is not broken, this "while" statement will loop.
    // when the laser is broken, the program will continue.

  // laser off
  // turn laser off to not show up in the picture
  // digitalWrite(laserPin, LOW);
*/

// what follows is the piezo code
PiezoReading = analogRead(PiezoPin);
Serial.print("Analog reading = ");
Serial.println(PiezoReading);     // the raw analog readingwhile (analogRead(PiezoPin)<1){
  Serial.println("no sound detected");
    int PiezoReading  = analogRead(PiezoPin); //read value photocell
    Serial.println(PiezoReading);
    }

    // Wait the amount indicated by the value of potentiometer
    // give the waves time to rise back to the surface
delay(reading);

  //trigger flash - send signal from pin 8
    digitalWrite(8, HIGH);
    Serial.println("FLASH fired");
    delay(1000);
    digitalWrite(8, LOW);

    //wait for flash light to die down
    delay(200);

    //close camera shutter

    Serial.println("END");
    // END OF (buttonpressed) while loop

  digitalWrite(laserPin, LOW);
}}

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}
Make the declaration global by inserting "int reading;" at line 25.

Remove the "int" before "reading" on line 48.

You also have an extra curly bracket on line 112 delete this.

There is also an extra "void setup()" and "void loop()" at the end of your code, delete every thing after line 113.

It should compile now, but I can't promise it will work.

I apologize if this reply doesn't display properly but I can't get a preview of my post. This is only my second posting.

Mod edit: move code out of quote - JohnInTX
 
Last edited by a moderator:

Thread Starter

gene-stevo

Joined Feb 22, 2019
13
C++:
/* This program is used as a laser trigger and/or sound trigger for high-speed photography<br>  ---> Made by Sander Vanhee <--

push button to activate program
Activate laser or sound trigger
delay
open camera shutter (manual for now)
drop an object
laser barrier or piezo sensor gets triggered
laser off
wait the delay set by potentiometer
trigger flash
delay
close camera shutter
delay
*/

int laserPin = 12;        // red wire from laser
int potPin = 0;           // potentiometer to read delay
int optoPin = 8;          // towards the optocoupler
int buttonApin = 2;       // pushbutton
int photocellPin = A1;    // the cell and 10K pulldown are connected to A1
int photocellReading;     // the analog reading from the sensor divider
int PiezoPin = A2;         // the Piezo is connected to a2
int PiezoReading;         // the analog reading from the sensor divider

void setup(){
  // We'll send debugging information via the Serial monitor
    Serial.begin(9600);

    //#define photocellPin 1
    pinMode(laserPin, OUTPUT);
    pinMode(buttonApin, INPUT);
    pinMode(photocellPin, INPUT_PULLUP);
    pinMode(PiezoPin, INPUT);
    pinMode(optoPin, OUTPUT);
    pinMode(potPin, INPUT_PULLUP);
    }

void loop() {
  // check if button is pressed, only continue when pressed.
    Serial.println("Waiting for buttonpress...");

if (digitalRead(buttonApin) == HIGH) {  // start program if button is pressed
    //start if(buttonpressed) loop
    Serial.println("Button pressed");
 
// Read value of potentiometer
    int reading  = analogRead(potPin);
    Serial.println("reading potentiometer");
    Serial.println(reading);
    reading = map(reading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)

delay(50);


/* We'll put the laser parts in comments to isolate them from the Piezo code

// Activate laser
    digitalWrite(laserPin, HIGH);
    Serial.println("Laser Activated");

delay(1000); // delay before open shutter

Serial.println("Drop object");

  // read the value of the photocellPin
    int photocellReading  = digitalRead(photocellPin); //read value photocell and print it
    Serial.println(photocellReading);

  //Check if laser is broken
while (digitalRead(photocellPin)==HIGH){
  Serial.println("Laser uninterrupted");
    int photocellReading  = digitalRead(photocellPin); //read value photocell
    Serial.println(photocellReading);

// as long as the laser is not broken, this "while" statement will loop.
    // when the laser is broken, the program will continue.

  // laser off
  // turn laser off to not show up in the picture
  // digitalWrite(laserPin, LOW);
*/

// what follows is the piezo code
PiezoReading = analogRead(PiezoPin);
Serial.print("Analog reading = ");
Serial.println(PiezoReading);     // the raw analog readingwhile (analogRead(PiezoPin)<1){
  Serial.println("no sound detected");
    int PiezoReading  = analogRead(PiezoPin); //read value photocell
    Serial.println(PiezoReading);
    }

    // Wait the amount indicated by the value of potentiometer
    // give the waves time to rise back to the surface
delay(reading);

  //trigger flash - send signal from pin 8
    digitalWrite(8, HIGH);
    Serial.println("FLASH fired");
    delay(1000);
    digitalWrite(8, LOW);

    //wait for flash light to die down
    delay(200);

    //close camera shutter

    Serial.println("END");
    // END OF (buttonpressed) while loop

  digitalWrite(laserPin, LOW);
}}

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}
Make the declaration global by inserting "int reading;" at line 25.

Remove the "int" before "reading" on line 48.

You also have an extra curly bracket on line 112 delete this.

There is also an extra "void setup()" and "void loop()" at the end of your code, delete every thing after line 113.

It should compile now, but I can't promise it will work.

I apologize if this reply doesn't display properly but I can't get a preview of my post. This is only my second posting.

Mod edit: move code out of quote - JohnInTX
Thank you so much for that. The sketch now compiles fine. The problem I now have (apart from a profound lack of understanding) is the nano wont acept the upload. I've tried uploading a default sketch, like Blink without sucess. I've tried different computers, different USB cables. Nothing works, apart from the power light and the blinking "L" light.
I've checked I'm using the correct port on each computer and selected nano from the board list.
Curiously when I check for board info this is the info I get:
BN: Unknown board
VID: 1A86
PID: 7523
SN: Upload any sketch to obtain it
After trying to upload I then get this error message:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x18
I bought a three pack of unsoldered nano boards (e-bay) and none of them will accept an upload. Is it likely I've bought a duff batch?
 

s14rs4

Joined Sep 15, 2016
75
Thank you so much for that. The sketch now compiles fine. The problem I now have (apart from a profound lack of understanding) is the nano wont acept the upload. I've tried uploading a default sketch, like Blink without sucess. I've tried different computers, different USB cables. Nothing works, apart from the power light and the blinking "L" light.
I've checked I'm using the correct port on each computer and selected nano from the board list.
Curiously when I check for board info this is the info I get:
BN: Unknown board
VID: 1A86
PID: 7523
SN: Upload any sketch to obtain it
After trying to upload I then get this error message:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x18
I bought a three pack of unsoldered nano boards (e-bay) and none of them will accept an upload. Is it likely I've bought a duff batch?
If they are from e-bay I assume they are Chinese clones. In the Tools menu when you select processor be sure to select ATmega328P(Old Bootloader). The newer genuine Arduino nano's use a different baud rate.
 

Thread Starter

gene-stevo

Joined Feb 22, 2019
13
If they are from e-bay I assume they are Chinese clones. In the Tools menu when you select processor be sure to select ATmega328P(Old Bootloader). The newer genuine Arduino nano's use a different baud rate.
Thanks so much for your quick responce, that did it. Upload worked first time (so I don't need a refund}. Bloody code doesn't work though. Back to the drawing board. All I'm trying to do if fire a flash (via optocoupler) in responce to a noise/vibration detected by piezo. I'll dig around in the default sketch library.
Thanks to all who responded and for your patience with an obvious newb. Very much appreciated.
 

djsfantasi

Joined Apr 11, 2010
9,156
Thanks so much for your quick responce, that did it. Upload worked first time (so I don't need a refund}. Bloody code doesn't work though. Back to the drawing board. All I'm trying to do if fire a flash (via optocoupler) in responce to a noise/vibration detected by piezo. I'll dig around in the default sketch library.
Thanks to all who responded and for your patience with an obvious newb. Very much appreciated.
If that is all you need right now, I've modified the sketch. I removed everything related to the laser, etc... Ive corrected several errors and this slim, trim sketch is all you need given the requirements you stated above...

Arduino Nano Sketch to Listen to a Piezo device and Trigger an Optocoupler:
// This program is used as a sound trigger for high-speed photography

int potPin = D4;            // potentiometer pin to read delay
                                     // pin 0 won't work because youre using Serial.println()
int PotReading = 0;       // pot reading/ set delay
int optoPin = D8;          // towards the optocoupler
int PiezoPin = A2;         // the Piezo is connected to a2
int PiezoReading = 0;         // the analog reading from the sensor divider
int PiezoDiff = 0;


void setup() {
  // We'll send debugging information via the Serial monitor
  Serial.begin(9600);

  pinMode(potPin, INPUT_PULLUP);
  pinMode(optoPin, OUTPUT);
  pinMode(PiezoPin, INPUT);
}

void loop() {
    int lastPiezoReading = 0;
   
    // Read value of potentiometer
    PotReading  = analogRead(potPin);
    Serial.println("reading potentiometer");
    Serial.println(PotReading);
    PotReading = map(PotReading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)
    delay(50);

    // what follows is the piezo code
    lastPiezoReading = analogRead(PiezoPin);
    Serial.print("Analog reading = ");
    Serial.println(PiezoReading);     // the raw analog readingwhile (analogRead(PiezoPin)<1){
    Serial.println("no sound detected");
    while(abs(lastPiezoReading-PiezoReading)<PiezoDiff) ; // loop while the piezo readings are close together
    //wait for Piezo to change significantly

  // Wait the amount indicated by the value of potentiometer
  // give the waves time to rise back to the surface
  delay(PotReading);

  //trigger flash - send signal from pin 8
  digitalWrite(8, HIGH);
  Serial.println("FLASH fired");
  delay(1000);  // delay 1 second
  digitalWrite(8, LOW);

  //wait for flash light to die down
  delay(200);

}
 

Thread Starter

gene-stevo

Joined Feb 22, 2019
13
If that is all you need right now, I've modified the sketch. I removed everything related to the laser, etc... Ive corrected several errors and this slim, trim sketch is all you need given the requirements you stated above...

Arduino Nano Sketch to Listen to a Piezo device and Trigger an Optocoupler:
// This program is used as a sound trigger for high-speed photography

int potPin = D4;            // potentiometer pin to read delay
                                     // pin 0 won't work because youre using Serial.println()
int PotReading = 0;       // pot reading/ set delay
int optoPin = D8;          // towards the optocoupler
int PiezoPin = A2;         // the Piezo is connected to a2
int PiezoReading = 0;         // the analog reading from the sensor divider
int PiezoDiff = 0;


void setup() {
  // We'll send debugging information via the Serial monitor
  Serial.begin(9600);

  pinMode(potPin, INPUT_PULLUP);
  pinMode(optoPin, OUTPUT);
  pinMode(PiezoPin, INPUT);
}

void loop() {
    int lastPiezoReading = 0;
  
    // Read value of potentiometer
    PotReading  = analogRead(potPin);
    Serial.println("reading potentiometer");
    Serial.println(PotReading);
    PotReading = map(PotReading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)
    delay(50);

    // what follows is the piezo code
    lastPiezoReading = analogRead(PiezoPin);
    Serial.print("Analog reading = ");
    Serial.println(PiezoReading);     // the raw analog readingwhile (analogRead(PiezoPin)<1){
    Serial.println("no sound detected");
    while(abs(lastPiezoReading-PiezoReading)<PiezoDiff) ; // loop while the piezo readings are close together
    //wait for Piezo to change significantly

  // Wait the amount indicated by the value of potentiometer
  // give the waves time to rise back to the surface
  delay(PotReading);

  //trigger flash - send signal from pin 8
  digitalWrite(8, HIGH);
  Serial.println("FLASH fired");
  delay(1000);  // delay 1 second
  digitalWrite(8, LOW);

  //wait for flash light to die down
  delay(200);

}
Huge thanks for that. I'll have another play tomorrow. Can't thank you enough for your trouble.
Cheers,
Eugene
 
Top