Arduino High pins supplying less then 5V

hi, i connected pin 9 to analog read 0 and set it to high it gives me 900 or 966 i noticed that its not giving me enough power when i tried to run some motors

i used mosfets and when i connected gate to arduinos VCC the motor ran at full speed (it was 12v i guess i used 7v anyway)

but when i connected to pin 9 using digitalWrite(9,HIGH) motor ran a little bit slower !!! well not really little !!

whats problem :o

i tried using 9V battery instead of USB but didnt work either (still 5V pins gives 5v but a HIGH pin gives around 4.5 i guess)

also if i give mosfet lower but not PWM singal less than 5v will motor run slower? or it most be PWM to work?

You can not run a few motors with the USB power or with a 9V battery.
Do you have a power supply ?
If you power the Arduino with the USB, and the motors with the power supply, it should be okay.

Perhaps you have a cheap usb cable and the voltage drops too much.

Or the mosfet is not a 'logic level' mosfet.

When the Arduino is running normal, the outputs and voltages should be good.
It is hard to tell what could be wrong.
Can you give the schematic and the sketch and perhaps a photo of your circuit ?

You don't want to run motors direct off the Arduino pins. They won't source enough voltage or current and inductive kickback from the motor(s) could be a source of damage.

Do what you did and run the motors off a separate power source with the Arduino switching a transistor and/or an H Bridge.

I powered motor externaly also this gives me 966 on serial my pc is off so o will do sumarry!!

Pin9to analog0 whit jumper

PinMode(9,OUTPUT) write high and serial out A0

It gives 900-966 connecting jumper to 5v from A0 gives 1024 no leds or anything to drain !! I know a motor would damage my board

Also note that connecting MOSFET gate to ARDUINOS 5v gives full speed not supplyssupplys but thats just how i found out about this!

Because the arduino pins employ mosfet push/pull drivers, there is pretty much no way you will get exactly gnd or vcc potential out of a pin. You will have potential loss due to passing through the active transistor at the pin in the chip. If your mosfet is behaving wildly different with only a small [few millivolt] difference, then i say... you are using the wrong mosfet.

kamhagh:
Also note that connecting MOSFET gate to ARDUINOS 5v gives full speed not supplyssupplys but thats just how i found out about this!

Connecting the gate directly to 5V DC will give full speed, due to the fact the gate is always on, therefore the MOSFET is always conducting.
Using pin9 like you are is a great way of using PWM to vary the speed of the motor, as it changes the amount of time the MOSFET is conducting, compared to the amount of time its non-conducting.
BUT your problem seems to be reading an output voltage using the ADC. Have you tried using a multimeter to read the voltage? Read both the 5V and then pin9 incase your multimeter has a slight offset.
It could be a problem with the ADC reading a value that is 5V (from pin9) but your 5V is actually 5.2V for instance.
Try that and get back to us. :slight_smile:

If pin 9 is only driving a MOSFET gate and is set HIGH (not PWM), then it should read 5V,
and analogRead will return 1023.

A mosfet gate is an extremely high resistance load so draws tiny current only, and the
Arduino pin driver will have it within a few millivolts of Vcc. The output resistance
of the Arduino pin drivers is about 40 ohms, MOSFET gate will be 10M ohms or more
unless its fried.

So you need to check the pin is only driving the MOSFET gate, that the gate is drawing
less than 1uA.

I'd also check pin 9 is working as expected with no load at all.

Its always wise to use 150 ohm or similar resistor between pin and gate since although
the gate has a high resistance, its extremely capacitive and draws spikes of current
when switching. Such a resistor can be used to measure any fault current flowing
from the pin too.

i guess i explained wrong heres sketch and full code


https://dl.dropboxusercontent.com/u/72156813/Screenshot%20from%202014-02-14%2012%3A36%3A01.png

this is sketch !!! just a wire from pin9 to a0 nothing else

void loop(){
Serial.begin(9600);
pinMode(9,OUTPUT);
digitalWrite(9,HIGH);

}

void setup(){
Serial.println(analogRead(0));
delay(100);
}

I hope you know that you exchanged the words 'setup' and 'loop' ?
Wat that the real sketch ? copied from the Arduino IDE ?

i didnt save it but i uploaded this still same thing

i didnt save it but i uploaded this still same thing

i can't copy it here

void setup(){
Serial.begin(9600);
pinMode(9,OUTPUT);
digitalWrite(9,HIGH);
}

void loop(){
Serial.println(analogRead(0));
delay(100);
}

i didnt really make any diffrence but suddenly it worked 0_0 !!!! maybe i had a connection problem( bad wires) my wires are horrible !!!