Go Down

Topic: beep when flash is charge up - registers flash (Read 95 times) previous topic - next topic

sobNorway

Hi. i was Trying to detect when my photo flash went of.. so arudino could tell me when to take next photo with more flash power. in lack of LDR (light dependet resistor) i chose to try a photo resistor in stead. one like this:
I used digital pin instead of Analog pin. and it register much good.

Here are my code and how i set it up.

 photo diode
 long pin to 10k resistor pin A and long pin to Ardunio digital pin 2
 shor pin to 5v

 the 10k resistor
 Pin A to gnd
 pin B to photo diod long pin

 pizo transduser 4Khz
 Black wire to gnd
 red wire to Digital pin 8.

 the code:
Code: [Select]
const int button = 2;//
int chargeTime=8000;
int hz=2600;
int buttonState = 0;

void setup() {
  pinMode(button, INPUT);
  tone(8,2600,100);delay(125);
  tone(8,600,100);delay(125);
  tone(8,2600,100);delay(125);
 
 
}

void loop() {
  buttonState = digitalRead(button);
  if (buttonState == HIGH)
  {// if 1
    tone(8,hz,50);delay(50);
    tone(8,hz/4,50);delay(50);
    delay(chargeTime);chargeTime=chargeTime+100;
    tone(8,hz,100);hz=hz-26;if (hz<0)hz=0;
  }
    else
  {// if not 1// just do nothing}
}
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy