lightning trigger with a phototransistor

I’m trying to build a lightning trigger with a phototransistor, I’ve used a circuit like in the attachemet.

So far everything works but when no (or just few) light falls on the sensor the analog input seems to bounce. Therefor I wrote the value to serial monitor and when it’s dark I get several lines with 0 and then values from 60 to 90 but when I fire my camera flash I get values from 150 to 800 depending on distance and direction.

int SHUTTER_PIN = 13;                   //set the camera shutter pin
int LIGHTNING_TRIGGER_ANALOG_PIN = 0;   //set the light sensor pin

int lightningVal = 0;                 //reading from sensor
int TRIGGER_THRESHOLD = 100;      // base sensor adjustment

void setup()
  Serial.begin(9600);                // set up Serial library at 9600 bps
  pinMode(SHUTTER_PIN, OUTPUT);      // Set the camera shutter pin as utput
  digitalWrite(SHUTTER_PIN, LOW);    // Set the initial state of shutter as off

  lightningVal = analogRead(LIGHTNING_TRIGGER_ANALOG_PIN);    //read the initial state of light sensor
void loop()
  int newLightningVal = analogRead(LIGHTNING_TRIGGER_ANALOG_PIN);  // Read the light sensor value
  if ((newLightningVal - lightningVal) > TRIGGER_THRESHOLD)    // if the new value of the light sensor is changed by more than the threshold

        digitalWrite(SHUTTER_PIN, HIGH);  //activate camera shutter
        delay(1000); // amount of time shutter is pressed and held 
        digitalWrite(SHUTTER_PIN, LOW);  //deactivate camera shutter
    lightningVal = newLightningVal;

Is there a way to reduce bouncing on the input?


You say you have a photo transistor and yet you show a photo diode on that diagram? Which is it.
It is not bounce it is interference pickup.

I have a photo transistor without base connection, sorry when I’ve used the wrong symbol. How can I get rid of interference pickup?

How can I get rid of interference pickup?

Short leads, and a 0.1uF ceramic capacitor between the analogue input and ground.

How are you powering the circuit?