Hello all,
I have an Arduino Mega 2560 and i'm trying to use pin 2 to send voltage to a transistor.
#define right_pin 2
#define led 3
void setup() {
// put your setup code here, to run once:
pinMode(right_pin, OUTPUT);
pinMode(led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(right_pin, HIGH);
digitalWrite(led, HIGH);
delay(250);
digitalWrite(right_pin, LOW);
digitalWrite(led, LOW);
delay(random(5)*1000);
}
The code sends power to 2 for the transistor and 3 for an LED.. It is simple enough and works great when i have USB plugged into the Arduino for power.. When i remove the USB and replace it with a 5v power supply to the 5v pin, the code starts working, the LED flashes normally, but the transistor will not fire.
The transistor is 2N3904
I'm sure it is something dumb, but i keep banging my head on this. I even added the LED just to know the code was still churning. Any thoughts?
Thanks,
Jay