1 volt?

ok so i wrote a very simple code (int dcr = 11; int dcl = 8;

void setup() { pinMode(dcr, OUTPUT); pinMode(dcl, OUTPUT);

}

void loop() { digitalWrite(dcr, HIGH); digitalWrite(dcl, HIGH);

}) and used it to switch some npn transistors to power two dc motor. The only problem is that its giving out 1 volt on pins 8 and 11 instead of 5 how do I fix this.

When posting code, is helpful to use the "#" button to wrap the code in code tags.

If a PIN is set to HIGH and it isn't at 5V it is usually because of two reasons: 1) The pin wasn't set to OUTPUT (which you did.) and 2) Too much current is being drawn.

What value resistor do you have between the pin and the base of the transistor?

I dont have one what do you recommend I use? Oh and the transistors are the standard ones you get at radio shack, part number 2N3904.

Oh and I don’t know if this helps or not but I’m powering the two dc motors from the 5v pin on the arduino.

I don't know if this helps or not but I'm powering the two dc motors from the 5v pin on the arduino.

You can't do that for any reasonable size motor. They draw far too much current.

hadjisra: I dont have one what do you recommend I use? Oh and the transistors are the standard ones you get at radio shack, part number 2N3904.

A 100ohm or 1kohm is generally a good idea. It helps to prevent too much current from flowing between the I/O pin and the transistor. You have to be careful to pick a value small enough so that there is enough current to turn on the transistor but large enough to limit it. I'd start with a 1k.

hadjisra: Oh and I don't know if this helps or not but I'm powering the two dc motors from the 5v pin on the arduino

And how are you powering the Arduino?

im using a 9 volt battery

im using a 9 volt battery

Not one of those dinky little smoke detector batteries, I hope. Those batteries are good for smoke detectors and precious little else.

hadjisra: im using a 9 volt battery

ou are likely drawing too much current through the Arduino's on-board regulator. It is a wonder the board doesn't reset when you turn on the motors.

Agree with Paul. If you're talking the PP3 style battery, that isn't going to work for powering a motor. You'd need 3 or 4 of them in parallel. 6 AAs would make much more sense.

ok so i replace the 9v with 6 aa's and that should work?

wait i did what you said but its still not working i still have the motors on the 5v pin but im powering the arduino with 6 aa's ihave a 220 ohm resistor to each base of the transistor and a 1k from the 5v pin to the collectors and the emitters to the motors

I also said you are probably drawing too much current through the Arduino's 5V regulator. I wouldn't power the motors from the 5V pin.

then how would you power them? oh and thanks for all the help

Im still stuck on how to power them? would I use another battery or amplifier?

Power the motors directly. There is no (or little) value in providing them regulated power.

wait directly from the pin or arduino power source or a completely different power source

hadjisra: wait directly from the pin or arduino power source or a completely different power source

Completely separate power supply is a good idea. What's the rating of yr motor in amps or watts?

wait directly from where?

wait directly from where

wait directly from where?

I haven't responded because I have no idea what you are asking. Asking the same question again is not likely to get any answers.