LED staying on very dimly
i have setup connect 2 seperate instances of led , photoresistor.
shine on photoresistor 1 ~3 sec, led 1 goes out.
shine on photoresistor 2 ~3 sec, led 2 goes out well.
you can put out led 2 if have first put out led 1.
only problem i"m having, after writing low led 1, there residual voltage keeping on. if shine laser on photoresistor 2 led dims more, not fully. when both leds written low dim.
i've measured through multimeter.
when led1 = low, receives 0,27v
when led1 = low , shine laser on photoresistor receives -0,03v
when led1 = low & led2 = low receives 0,00v
click here photo
what heck
shine on photoresistor 1 ~3 sec, led 1 goes out.
shine on photoresistor 2 ~3 sec, led 2 goes out well.
you can put out led 2 if have first put out led 1.
only problem i"m having, after writing low led 1, there residual voltage keeping on. if shine laser on photoresistor 2 led dims more, not fully. when both leds written low dim.
i've measured through multimeter.
when led1 = low, receives 0,27v
when led1 = low , shine laser on photoresistor receives -0,03v
when led1 = low & led2 = low receives 0,00v
click here photo
what heck
code: [select]
/* blind cyclops!
het doel van dit spel om de photoresistor te raken met de laserstraal en zo de cycloop te verblinden. als de taak geslaagd dooft de led boven het hoofd van de cycloop.
als het oog van de ene cycloop verblind kan er nog een tweede oog aan toegevoegd worden om de puzzel te vermoeilijken. daarbij kan bijvoorbeeld een specifieke tijd ingesteld
worden waarbinnen de twee triggers af moeten gaan. de ogen van de cyclopen kunnen namelijk herstellen!
*/
//the laser
const int laserpin = 12; // define laser pin
//the first eye
const int ledpin1 = 4; // define left led pin
const int photopin1 = a0; // define left analog photoresistor pin
int photovalue1 = 0; // initialize photoresistor
int val1 = 0;
int blinded1 = 0;
//the second eye
const int ledpin2 = 10; // define left led pin
const int photopin2 = a1; // define left analog photoresistor pin
int photovalue2 = 0;
int val2 = 0;
int blinded2 = 0;
void setup() {
pinmode(laserpin, output); // define laser pin output
pinmode(ledpin1, output); // define led pin output
pinmode(ledpin2, output); // define led pin output
serial.begin(9600); // start communication serial monitor
}
void loop() {
photovalue1 = analogread(photopin1); // read value photoresistor
photovalue2 = analogread(photopin2);
// serial.println(photovalue); // comment calibration purposes
digitalwrite(ledpin1, high);
digitalwrite(ledpin2, high);
digitalwrite(laserpin, high); // initialize laser beam
if (blinded1 != true && blinded2 != true){
if (photovalue1 > 992 ) { // check whether laser beam triggering photoresistor. adapt equation calibration value.
val1++; // if is, start incrementing val 1
serial.print("val1 count is");
serial.println(val1);
if (val1 == 100){ // when val reaches 3000, kill cyclops
blinded1 = true;
digitalwrite(ledpin1,low);
serial.print("you have blinded first cyclops");
}
}
else { // if laser beam stops triggering photoresistor before val reaches 50, reset val
val1 = 0;
}
}
if (blinded2 != true && blinded1 == true){
digitalwrite(ledpin1,low);
if (photovalue2 > 992) { // check whether laser beam triggering photoresistor. adapt equation calibration value.
val2++; // if is, start incrementing val 1
serial.print("val2 count is");
serial.println(val2);
if (val2 == 100){ // when val reaches 3000, kill cyclops
blinded2 = true;
digitalwrite(ledpin2,low);
digitalwrite(laserpin, low); // kill laser safety purposes
}
}
else { // if laser beam stops triggering photoresistor before val reaches 50, reset val
val2 = 0;
}
}
if (blinded2 == true && blinded1 == true){
serial.write("you have blinded both cyclopses, succes!!");
delay(10000);
blinded1 = false;
blinded2 = false;
val1 == 0;
val2 == 0;
}
}
i suspect loop running faster imagine. both leds getting high @ beginning of every time loops. dimness looks steady merely alternating rapidly. dims further when more happens second stuff because ever prolongs low before high @ top of loop.
Arduino Forum > Using Arduino > LEDs and Multiplexing > LED staying on very dimly
arduino
Comments
Post a Comment