Hi Guys,
I'm in need of some help here. I want to use an uno to fire a small laser pointer. I want the laser to only fire if pins 6 and 7 are high, and turn of if the condition is not met.. In lieu of actually plugging in a laser, I'm assigning the 'firing' pin to 13, and will use the smd led on the board as an indicator. I've prepared some code, thinking it should be easy, but I have 2 problems:
problem #1:
I plug in 5v from the arduino's 5v pin into both pin 6 and 7. pin 13 lights up. When I unplug the 5V, there's a 1 to 2 second delay before the led on pin 13 turns off. It's awfully frustrating.. Why is this?
Problem #2:
I sometimes am able to trigger pin 13 by just powering one of the input pins. What am I doing wrong?
Thanks in advanced! :):)
// pin assignments
int PhotoCell = 0;
const int Signal_1 = 6;
const int Signal_2 = 7;
int Signal_1_State = LOW;
int Signal_2_State = LOW;
int LaserTrigger = 13; //8
long previousMillis = 0;
//unsigned long currentMillis = 0;
long interval = 250;
int ledState = LOW;
const int ledPin = 13;
void setup()
{
pinMode(PhotoCell, INPUT);
pinMode(Signal_1, INPUT);
pinMode(Signal_2, INPUT);
pinMode(LaserTrigger, OUTPUT);
//Serial.begin(9600);
}
void loop()
{
LaserRelay();
}
void LaserRelay()
{
Signal_1_State = digitalRead(Signal_1);
Signal_2_State = digitalRead(Signal_2);
if(Signal_1_State == HIGH) {digitalWrite(LaserTrigger,HIGH);}
else { digitalWrite(LaserTrigger,LOW);}
}