Hello everyone. This is my first stop in this section as I have just lumped into the land of the Arduino.
I have added a circuit that will be 1 of up to 12 I plan to use/control. I have been trying to get up to speed on the programming side of things and I have already hit my first snag.
First, here is the circuit.
I have tried to write a simple sketch assigning 1 digital pin as an input "written" to LOW and 1 digital output pin written to LOW.
For some reason, as soon as the unit powers up, the digital output pin is HIGH - even if nothing is connected at the input pin.
Eventually I plan to feed the voltage divider into an analog pin and hopefully control the corresponding laser accordingly. But that will wait until I can get the laser to come on with the press of a PB.
One other potential issue I am wondering about is when more lasers get online. My plan is to use 1 initial press of the PB to set multiple lasers to high (say 4 total). Then, depending on when the laser is tripped, it will shut off for a set time and then go back on. Needless to say I will be back with more programming questions when I get that far!
My other question involves using an output pin to close the 2n2222 transistor. Is that acceptable? The current over the laser/LDR circuit was measured at 25mA @ 5.1V. It is unclear to me if the Arduino will only be sourcing the fractional current necessary to close the transistor or potentially see the larger amount. Obviously I do not want to fry it? Sorry about digressing into non-programming things ...
Thanks in advance for your help.
I have added a circuit that will be 1 of up to 12 I plan to use/control. I have been trying to get up to speed on the programming side of things and I have already hit my first snag.
First, here is the circuit.
I have tried to write a simple sketch assigning 1 digital pin as an input "written" to LOW and 1 digital output pin written to LOW.
For some reason, as soon as the unit powers up, the digital output pin is HIGH - even if nothing is connected at the input pin.
I am just starting out and I am not sure when items should be at the top of the program, in the setup or loop sections. Do i have something wrong?//Laser Maze Program
//Assign laser units to pins
const int laser1 = 22;
const int pbeasy = 51; //This PB, when HIGH will turn on laser1 to
//start the game.
void setup()
{
pinMode(laser1, OUTPUT);
pinMode(pbeasy, INPUT);
digitalWrite(pbeasy, LOW);
digitalWrite(laser1, LOW);
}
void loop()
{
if(pbeasy == HIGH);
digitalWrite(laser1, HIGH);
delay(2000);
digitalWrite(laser1, LOW);
}
Eventually I plan to feed the voltage divider into an analog pin and hopefully control the corresponding laser accordingly. But that will wait until I can get the laser to come on with the press of a PB.
One other potential issue I am wondering about is when more lasers get online. My plan is to use 1 initial press of the PB to set multiple lasers to high (say 4 total). Then, depending on when the laser is tripped, it will shut off for a set time and then go back on. Needless to say I will be back with more programming questions when I get that far!
My other question involves using an output pin to close the 2n2222 transistor. Is that acceptable? The current over the laser/LDR circuit was measured at 25mA @ 5.1V. It is unclear to me if the Arduino will only be sourcing the fractional current necessary to close the transistor or potentially see the larger amount. Obviously I do not want to fry it? Sorry about digressing into non-programming things ...
Thanks in advance for your help.
Last edited: